
在 php 中,可以通过数据库查询获取到这样的数据对象:
object(think\collection)#117 (1) {
["items":protected] => array(10) {
[0] => array(5) {
["id"] => int(2)
["post_id"] => int(7)
["category_id"] => int(9)
["list_order"] => float(10000)
["status"] => int(1)
}
...
}
}要将此对象转换为数组,可以使用 toarray 方法:
$data->toarray();
这样就能得到一个标准的 php 数组:
array(10) {
[0] => array(5) {
["id"] => int(2)
["post_id"] => int(7)
["category_id"] => int(9)
["list_order"] => float(10000)
["status"] => int(1)
}
...
}











