如何将对象作为存储在数组中的字符串进行回显?

时间:2013-12-01 06:22:13

标签: php arrays object

我想从这个数组中回显cer_type

 Array
    (
        [0] => stdClass Object
            (
                [id] => 1
                [cer_type] => S.L.C.
            )

        [1] => stdClass Object
            (
                [id] => 3
                [cer_type] => Intermediate
            )
    )

1 个答案:

答案 0 :(得分:2)

试试这个:

<?php

    echo $array[0]->cer_type;

    // or if you want to loop through the array:

    foreach ($array as $element) {
        echo $element->cer_type;
    }