“阵列"一词打印而不是行的值 [英] The word "Array" gets printed instead of the values of the rows
本文介绍了“阵列"一词打印而不是行的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
好的,我是 CI 和 MySQL 的新手.这是我的代码:
Okay,i'm a newbie to CI and MySQL. This is my code:
<?php
class Trail2 extends CI_Controller{
public function boo() {
$this->load->database();
$this->load->helper('html');
$ret="SELECT * from posts";
$query=$this->db->query($ret);
foreach($query->result_array() as $row)
{
echo br(1);
echo $row;
}
}
}
?>
这将返回单词Array"代替行的值.我似乎无法弄清楚为什么.提前致谢.:)
and this returns the word "Array" in place of the values of the rows. I cant seem to figure out why though. Thanks in advance. :)
推荐答案
使用
var_dump($row);
代替
echo $row;
如果您只想查看数组的值,您可以执行以下操作
and if you just want to see the values of the array you can do something like the following
for ($var = 0; $var < sizeof($row); $var++) echo $row[$var].", ";
这篇关于“阵列"一词打印而不是行的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文