dozug64282 2017-04-04 20:12
浏览 31
已采纳

如何回显此数组的值? [重复]

This question already has an answer here:

can someone help me to echo [file] value and [label] value from following array:

Array
(
    [0] => stdClass Object
        (
            [label] => 360p
            [type] => video/mp4
            [file] => /uploads/myVideo.mp4
            [res] => 360p
        )

    [1] => stdClass Object
        (
            [label] => 720p
            [type] => video/mp4
            [file] => /uploads/myVideo.mp4
            [res] => 720p
        )

    [2] => stdClass Object
        (
            [label] => 480p
            [type] => video/mp4
            [file] => /uploads/myVideo.mp4
            [res] => 480p
        )

)
</div>
  • 写回答

2条回答 默认 最新

  • doubo4824 2017-04-04 20:16
    关注

    You can foreach to loop through all item and call in the array like:

    foreach($yourArray as $item) {
        echo $item->label;
        echo $item->file;
    }
    

    Or you can be using json_decode to cast your object to the array.

    $result = json_decode($data, true);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?