从php中的多维数组对象中检索数据

时间:2014-03-07 07:41:37

标签: php arrays multidimensional-array

我有一个这种格式的数组

stdClass Object
(
    [uid] => 245
    [status] => 1
    [filename] => test_image.png
    [uri] => temporary://test_image.png
    [filemime] => image/png
    [filesize] => 58140
    [source] => upload
    [destination] => temporary://test_image.png
    [fid] => 3312
    [timestamp] => 1394177272
    [type] => image
    [field_replacement] => stdClass Object
        (
            [uid] => 245
            [status] => 1
            [filename] => test_image.png
            [uri] => temporary://test_image.png
            [filemime] => image/png
            [filesize] => 58140
            [source] => upload
            [destination] => temporary://test_image.png
            [fid] => 3312
            [timestamp] => 1394177272
            [type] => image
            [field_replacement] => stdClass Object
                (
                    [uid] => 245
                    [status] => 0
                    [filename] => test_image.png
                    [uri] => temporary://test_image.png
                    [filemime] => image/png
                    [filesize] => 58140
                    [source] => upload
                    [destination] => temporary://test_image.png
                    [fid] => 3312
                    [timestamp] => 1394177272
                    [original] => stdClass Object
                        (
                            [fid] => 3312
                            [uid] => 245
                            [filename] => test_image.png
                            [uri] => temporary://test_image.png
                            [filemime] => image/png
                            [filesize] => 58140
                            [status] => 1
                            [timestamp] => 1394177135
                            [type] => image
                            [rdf_mapping] => Array
                                (
                                )

                        )

                    [type] => image
                )

            **[original] => stdClass Object
                (
                    [fid] => 3312
                    [uid] => 245
                    [filename] => test_image.png
                    [uri] => temporary://test_image.png
                    [filemime] => image/png
                    [filesize] => 58140
                    [status] => 0
                    [timestamp] => 1394177272
                    [type] => image
                    [rdf_mapping] => Array
                        (
                        )

                )**

        )

)

现在需要检索此值

           **[original] => stdClass Object
            (
                [fid] => 3312
                [uid] => 245
                [filename] => test_image.png
                [uri] => temporary://test_image.png
                [filemime] => image/png
                [filesize] => 58140
                [status] => 0
                [timestamp] => 1394177272
                [type] => image
                [rdf_mapping] => Array
                    (
                    )
            )**

如何在php中完成它。

2 个答案:

答案 0 :(得分:2)

$original = $object->field_replacement->original;
var_dump($original);

答案 1 :(得分:2)

这不是PHP数组。这是一个php对象。因此,您可以使用箭头( - >)进行如下访问。

$your_object->field_replacement->original