How to convert php result set to array: first get the object result set through "$this->db->get();"; then use "while($value = $row-> fetch_array()) {$result[]=$value;}" can be converted into an array.
The operating environment of this article: Windows 7 system, PHP version 7.1, DELL G3 computer
PHP queries the database, and the object result set is converted into an array
$row = $this->db->get();//得出对象结果集 $result = array(); if($row) { //转化为数组 while($value = $row->fetch_array()) { $result[] = $value; } } print_r($result);eixt; return $result;
$result=$mysql_query("select `id` from table_a"); $ar=array(); while($rows=$mysql_fetch_array($result)) { $ar[] = rows['id'];//把id存放到数组里 }
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to convert php result set to array. For more information, please follow other related articles on the PHP Chinese website!