File: example_show_json.php

package info (click to toggle)
httping 4.4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 468 kB
  • sloc: ansic: 4,475; python: 66; php: 15; makefile: 12
file content (40 lines) | stat: -rw-r--r-- 717 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<HTML>
<BODY>
<TABLE BORDER='1'>
<TR><TH>sequence</TH><TH>data</TH></TR>
<?
	$handle = popen('./httping -c 3 www.google.com -F -M', 'r');
	$read = '';
	while($line = fgets($handle))
		$read .= ' '.$line;
	fclose($handle);

	$fields = json_decode($read);

	for($index=0; $index<count($fields); $index++)
	{
		?><TR><?
		?><TD><? print $index + 1; ?></TD><?
		?><TD><? ?></TD><?
		?></TR><?

		?><TR><?
		?><TD><? ?></TD><?
		?><TD><?
			?><TABLE><?
			?><TR><TH>key</TH><TH>value</TH></TR><?
			foreach($fields[$index] as $key => $value)
			{
				?><TR><?
				?><TD><? print $key; ?></TD><?
				?><TD><? print $value; ?></TD><?
				?></TR><?
			}
			?></TABLE><?
		?></TD><?
		?></TR><?
	}
?>
</TABLE>
</BODY>
</HTML>