ホームページ >バックエンド開発 >PHPチュートリアル >PHPループでこのデータを読み取るにはどうすればよいですか?

PHPループでこのデータを読み取るにはどうすればよいですか?

WBOY
WBOYオリジナル
2016-06-23 14:38:20876ブラウズ

本文:[
{"bucket_name":"wulinag09","status":"0","cdatetime":"1385619473","used_capacity":"0","total_capacity":"0","re​​gion": "北京"}、
{"バケット名":"wulinag08","ステータス":"0","cdatetime":"1385619360","used_capacity":"0","total_capacity":"0","re​​gion" :"北京"},
{"バケット名":"wulinag07","ステータス":"0","cdatetime":"1385619169","used_capacity":"0","total_capacity":"0","re​​gion ":"北京"},
{"バケット名":"wulinag06","ステータス":"0","cdatetime":"1385618406","used_capacity":"0","total_capacity":"0","地域":"北京"},
{"バケット名":"wulinag05","ステータス":"0","cdatetime":"1385618247","used_capacity":"0","total_capacity":"0", "region":"beijing"},
{"bucket_name":"wulinag04","status":"0","cdatetime":"1385618074","used_capacity":"0","total_capacity":"0" ,"region":"beijing"},
{"bucket_name":"wulinag03","status":"0","cdatetime":"1385435678","used_capacity":"0","total_capacity":"0 ","re​​gion":"beijing"},
{"bucket_name":"wulinag02","status":"0","cdatetime":"1385435395","used_capacity":"0","total_capacity":" 0","re​​gion":"beijing"}
]


这数据我不知道是什么形式,如何列出每行的データデータ这里有8行データ,我想用前端表格的形式输出8行,然后用变量 读取実行的データ 例:
$rs[bucket_name] 能得 wulinag09
$rs[status] 能得 0
$rs[cdatetime] 能得 1385619473

推次例推


回复讨论(解决方案) )

json数格式,意思是本体の值は整然後面の内容,完整番号如下

<?$body = '[	{"bucket_name":"wulinag09","status":"0","cdatetime":"1385619473","used_capacity":"0","total_capacity":"0","region":"beijing"},	{"bucket_name":"wulinag08","status":"0","cdatetime":"1385619360","used_capacity":"0","total_capacity":"0","region":"beijing"},	{"bucket_name":"wulinag07","status":"0","cdatetime":"1385619169","used_capacity":"0","total_capacity":"0","region":"beijing"},	{"bucket_name":"wulinag06","status":"0","cdatetime":"1385618406","used_capacity":"0","total_capacity":"0","region":"beijing"},	{"bucket_name":"wulinag05","status":"0","cdatetime":"1385618247","used_capacity":"0","total_capacity":"0","region":"beijing"},	{"bucket_name":"wulinag04","status":"0","cdatetime":"1385618074","used_capacity":"0","total_capacity":"0","region":"beijing"},	{"bucket_name":"wulinag03","status":"0","cdatetime":"1385435678","used_capacity":"0","total_capacity":"0","region":"beijing"},	{"bucket_name":"wulinag02","status":"0","cdatetime":"1385435395","used_capacity":"0","total_capacity":"0","region":"beijing"}]';$arrbody = json_decode($body);?><table border=1><tr>	<td>bucket_name</td>	<td>status</td>	<td>cdatetime</td>	<td>used_capacity</td>	<td>total_capacity</td>	<td>region</td></tr><?foreach($arrbody as $key=>$value){?><tr><?	foreach($value as $k=>$var){		echo "<td>$var</td>";	}?></tr><?}?></table>

結果:

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。