Foreach值来自数组内的数组

时间:2013-04-11 22:16:01

标签: php arrays var-dump

嗨我需要得到一个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" } } }

我需要以http://

开头的2个img url字符串

任何帮助都将不胜感激。

谢谢

2 个答案:

答案 0 :(得分:2)

这应该有效:

foreach($var['docs'] as $sub) {
    echo $sub['imgurl'];
}

答案 1 :(得分:1)

foreach ($arr['docs'] AS $key => $link) {
  echo $link['imgurl'].'<br />';
}