如何从多维数组中提取值

时间:2012-11-01 14:18:01

标签: multidimensional-array

我有这个多维数组:

Array
(
    [car] => Array
        (
            [responsecode] => 200
            [ford] => Array
                (
                    [start] => 0
                    [count] => 20
                    [model] => 972000
                    [results] => Array
                        (
                            [0] => Array
                                (
                                    [date] => 
                                    [clickurl] => xx
                                    [url] => xx
                                    [dispurl] => xx
                                    [title] => xx
                                    [abstract] => xx
                                )

                            [1] => Array
                                (
                                    [date] => 
                                    [clickurl] => xx
                                    [url] => xx
                                    [dispurl] => xx
                                    [title] => Txx
                                    [abstract] => xx
                                )

我需要从 [型号] (972000)

中检索值

对我来说真的很难。提前谢谢!

2 个答案:

答案 0 :(得分:1)

如果您将数组分配给变量,请说$ arry那么它将是

$arry['car']['ford']['model']

还有其他技术可以从阵列中的每个“汽车”中获取“模型”,这是您正在寻找的吗?

答案 1 :(得分:1)

<?php
$array = array(
    "foo" => "bar",
    42    => 24,
    "multi" => array(
             "dimensional" => array(
                     "array" => "foo"
         )
    )
);

var_dump($array["foo"]);
var_dump($array[42]);
var_dump($array["multi"]["dimensional"]["array"]);
?>

http://php.net/manual/en/language.types.array.php