我如何获得数组内的值?

时间:2014-07-22 06:18:53

标签: php arrays multidimensional-array

我想在封面数组中获取[source]的值。我该怎么办?感谢。

Array
(
    [cover] => Array
    (
        [id] => 763132827070934
        [offset_y] => 29
        [source] => https://scontent-a.xx.fbcdn.net/hphotos-xap1/t31.0-8/q71/s720x720/10507065_763132827070934_644083226197727503_o.jpg
    )

    [id] => 123456789000
)

2 个答案:

答案 0 :(得分:0)

像这样:

$array['cover']['source'];

答案 1 :(得分:0)

<?php 
$data = Array
     (
        [cover] => Array
        (
            [id] => 763132827070934
            [offset_y] => 29
            [source] => https://scontent-a.xx.fbcdn.net/hphotos-xap1/t31.0-8/q71/s720x720/10507065_763132827070934_644083226197727503_o.jpg
        )

         [id] => 123456789000
      )

echo $data['cover']['source'];
?>