-1

我到底如何从这个数组中获取 id 和名称(可能通过使用 ForEach 构造)?

stdClass Object (
 [data] => Array ( 
    [0] => stdClass Object ( [name] => Corinne Culbard [id] => 5005561918 ) 
    [1] => stdClass Object ( [name] => Tom West [id] => 5034297044 ) 
    [2] => stdClass Object ( [name] => Sabri Tasci [id] => 5057373639 )
4

1 回答 1

3

这不工作吗?

foreach ($object->data as $item) {
    $name = $item->name;
    $id = $item->id;
}
于 2013-01-07T16:43:52.260 回答