PDA

View Full Version : http with php


Bussyman
18/04/2017, 07:19 AM
Hi,

I i'am using http to call to php file, there i want to load something, like 10 last killer names, and send again to my callback. I don't know how to make answer, i know need use echo, but if there 10 names, how to echo that? and how in callback get it values.

OsteeN
18/04/2017, 09:44 AM
You could use JSON.

Zav1337
18/04/2017, 03:42 PM
Like OsteeN said, you could use JSON. I made small script for you. This is how your php file could look like if you use JSON.

<table width="500">
<tr>
<td> Killer </td>
<td> Weapon </td>
<td> Player </td>
</tr>
<?php
$i = 0;
$json = json_decode(file_get_contents("JSON URL"));
foreach($json->kills as $data)
{
if ($i++ == 10) break;
echo "<tr>";
echo "<td>".$data->killer."</td>";
echo "<td>".$data->weapon."</td>";
echo "<td>".$data->player."</td>";
echo "</tr>";
}
?>
</table>