我是PHP新手,我有以下JSON,我想打印每个数组的值。
JSON
[
["38", "App Name1", "Long description.", "http:\/\/url.com", "5"],
["12", "Name 2", "Long description goes here...", "http:\/\/test.com", "100"]
]
我希望将其打印为:
App Name 1 Long description http://url.com 5 Name 2 Long description goes here... http://test.com 100
我无法让它发挥作用。任何人都可以帮我这个吗?
答案 0 :(得分:0)
试试这个
$a='[
["38", "App Name1", "Long description.", "http:\/\/url.com", "5"
],
["12", "Name 2", "Long description goes here...", "http:\/\/test.com", "100"
]
]';
$ja=json_decode($a);
if(count($ja)>0)foreach($ja as $jv){
echo $jv[1]."<br/>";
echo $jv[2]."<br/>";
echo $jv[3]."<br/>";
echo $jv[4]."<br/><br/>";
}
output:
App Name1
Long description.
http://url.com
5
Name 2
Long description goes here...
http://test.com
100