有人可以帮我回复以下数组中的[file]值和[label]值:
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
)
)
答案 0 :(得分:1)
您可以像这样访问stdClass
内的元素:
foreach ($test as $v) {
echo $v->file;
echo $v->label;
}
答案 1 :(得分:0)
您可以foreach
遍历所有项目并在数组中调用,如:
foreach($yourArray as $item) {
echo $item->label;
echo $item->file;
}
或者您可以使用json_decode
将对象转换为数组。
$result = json_decode($data, true);