【发布时间】:2013-09-06 07:44:45
【问题描述】:
我在下面的代码中获取数组值
$userdays_template=$this->templateroutinemodel->get_AllDays_by_templateRoutine_id($rid);
然后我打印了(echo("---userdays_template--.var_dump($userdays_template));)
它给了我这样的输出:array(4) { [0]=> string(3) "965" [1]=> string(3) "964" [2]=> string(3) "959" [3]=> string(3) "958" }
所以我的问题是,如何在循环中从这个数组中获取每个值?...
我尝试了什么:
$userdays_template=$this->templateroutinemodel->get_AllDays_by_templateRoutine_id($rid);
echo("---userdays_template---------".var_dump($userdays_template));
if (is_array($userdays_template))
{
foreach ($userdays_template as $row)
{
$day_value= $row->day_id;;
echo("---day---------".$day_value);//not printing the this line,why?
}
}
但它没有打印这个回声(echo("---day---------".$day_value);)。请帮帮我
【问题讨论】:
-
看起来你有一个数组,而不是一个对象。试试
$day_value = $row; -
@billyonecan 感谢您的回答帮助。它工作正常。只需在回答表单中回答您的评论,以便我可以接受您的回答,--majority 给你,因为你已经先回答了
标签: php codeigniter