doushan1850 2014-04-03 16:23
浏览 26
已采纳

获取具有精确键的对象数组的对象

Array
    (
        [1] => stdClass Object
            (
                [position] => 1
                [priority] => 1
                [percentage] => 100
            )
        [131] => stdClass Object
            (
                [position] => 11
                [priority] => 12
                [percentage] => 80
            )


    )

this is my array of objects.

Why I cant get object with like this: $a = $niz[1] ?

  • 写回答

1条回答 默认 最新

  • dongqiang1226 2014-04-03 16:28
    关注

    Convert the stdClass object to php array so you can access it by normal way.

    $niz = get_object_vars($niz);
    $a = $niz[1];
    
    print_r($a);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?