-3

嗨,我需要获取一个 var 的值,在将其设置为 var_dump($var) 之后,我得到:

array(1) {
    ["docs"]=> array(3) { 
        [0]=> array(1) { 
            ["imgurl"]=> string(68) "http://xxxxx.com/demos/grider/wp-content/uploads/2013/02/22.jpg" } 
        [1]=> array(1) { 
            ["imgurl"]=> string(68) "http://xxxxx.com/demos/grider/wp-content/uploads/2013/02/33.jpg" } 
        [2]=> array(1) { 
            ["imgurl"]=> string(68) "http://xxxxx.com/demos/grider/wp-content/uploads/2013/02/22.jpg" } } }

我需要 foreach 以 http:// 开头的 2 个 img url 字符串

任何帮助,将不胜感激。

谢谢

4

2 回答 2

2

This should work:

foreach($var['docs'] as $sub) {
    echo $sub['imgurl'];
}
于 2013-04-11T22:18:01.613 回答
1
foreach ($arr['docs'] AS $key => $link) {
  echo $link['imgurl'].'<br />';
}
于 2013-04-11T22:20:11.210 回答