Array(
[MainArray]=>Array
(
[myarray] => Array
(
[0] => Array
(
[id] => 1234
[url] => google.com
)
[1] => Array
(
[id] => 675677
[url] => stackoverflow.com
)
[2] => Array
(
[id] => 234234
[url] => test.com
)
)
)
)
我想要的是选择符合id的网址 因此,如果ID为1234,则网址应为google.com
我有这段代码
foreach($MainArray['myarray'] as $arr){
$url = $arr['url'];
}
但它给了我这三个。我需要过滤它们 感谢
答案 0 :(得分:2)
foreach($MainArray['myarray'] as $arr)
{
if ($arr['id'] == 1234)
{
$url = $arr['url'];
break;
}
}