如何将对象数组转换为数组? [英] How to convert the array of objects into an array?

查看:139
本文介绍了如何将对象数组转换为数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码是用CodeIgniter编写的,作为我的模型的方法。

  function get_user(){
$ result = $ this-> db-> get('users_table') - > result();
}

$ result 是由于运行数据库查询而产生的对象数组,在数组中转换 $ result 的最佳方法是什么?

result_array()函数代替 result()


The following code are written in CodeIgniter, as a method of my model.

function get_user () {
 $result = $this->db->get('users_table')->result();
}

the $result is the resulting array of objects as the result of running database query, what is the best way to convert $result in an array?

解决方案

Try with result_array() function instead of result()

这篇关于如何将对象数组转换为数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆