我在24小時的黑客馬拉松試圖解決這個問題,所以請原諒它是否有點匆忙。在另一個foreach json循環中循環一次foreach json循環
1 for each循環工作得很好,我是從這個URL獲得類別列表
https://dev.xola.com/api/categories
我抓住這個
$fullurl = "https://dev.xola.com/api/categories";
$string .= file_get_contents($fullurl); // get json content
$json_a = json_decode($string, true); //json decoder
然後用這個
循環播放列表<?
foreach($json_a as $v)
{?>
echo $v ?}>
現在,每個外觀的第二個,我想抓取這個URL的項目
https://dev.xola.com/api/experiences
從最後瀏覽的網址
so samething
$fullurl = "https://dev.xola.com/api/categories";
$string .= file_get_contents($fullurl); // get json content
$json_b = json_decode($string, true); //json decoder
這裏匹配的類別,
是完整的循環我試着
<?
$i=0;
foreach($json_a as $v)
$ I ++ {?> 回聲$ V?
foreach($json_b as $x){?>
if($v==$x):
echo $v
endif;
?>
}?>
有一些錯字錯誤,請首先糾正他們 –
'$ 1 = 0;'? PHP變量不能以數字開頭。 –
固定問題... – user2320607