可能重复:
混合数组和对象
我print_r
用来查看数组包含的内容:
Array (
[2] => stdClass Object (
[id] => 2
[category] => 1
[sortorder] => 10001
[shortname] => 2323
[fullname] => asdaSDa
[startdate] => 1343188800
[visible] => 1
[groupmode] => 0
[groupmodeforce] => 0
[numsections] => 10
[role] => student
[rolename] => Student
)
)
我想检索[id]
. 如何使用 PHP 实现这一点?
我尝试了以下方法,但从服务器收到异常 500:
echo "<h1>CODIGO: ".$courses[2]["id"]."</h1>";
有什么建议么?