本站资源收集于互联网,不提供软件存储服务,每天免费更新优质的软件以及学习资源!

PHP中ThinkPHPCollection对象如何转换为标准数组?

网络教程 app 1℃

PHP中ThinkPHPCollection对象如何转换为标准数组

在 php 中,可以通过数据库查询获取到这样的数据对象:

object(thinkcollection)#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) } …}

以上就是PHP中ThinkPHP Collection对象如何转换为标准数组?的详细内容,更多请关注范的资源库其它相关文章!

转载请注明:范的资源库 » PHP中ThinkPHPCollection对象如何转换为标准数组?

喜欢 (0)