从数组 PHP 读取
Read from array PHP
我正在尝试从下面的数组中提取 UserID,但我收到了这条消息:
A PHP Error was encountered
Severity: Notice
Message: Undefined index: profile_picture
Filename: views/profile_view.php
Line Number: 52
数组:
array (size=1)
'profile_picture' =>
array (size=1)
0 =>
object(stdClass)[21]
public 'UserID' => string '43' (length=2)
public 'PictProfFlag' => string '1' (length=1)
public 'PictPath' => string 'http://cms/uploads/category_icon.png' (length=36)
我是这样打印的:
foreach($profile_picture as $row)
{
echo $row->UserID;
}
我正在使用 Codeigniter 框架。
请帮忙
我刚刚解决了我的问题。
我正在从以下模型中检索数据:
控制器:
$this->get_user_pictures($id);
型号:
$data['profile_picture'] = $this->profile_model->picture($id);
并返回数组 $data 而不是 $data['profile_picture']
现在可以用了,谢谢
我正在尝试从下面的数组中提取 UserID,但我收到了这条消息:
A PHP Error was encountered
Severity: Notice
Message: Undefined index: profile_picture
Filename: views/profile_view.php
Line Number: 52
数组:
array (size=1)
'profile_picture' =>
array (size=1)
0 =>
object(stdClass)[21]
public 'UserID' => string '43' (length=2)
public 'PictProfFlag' => string '1' (length=1)
public 'PictPath' => string 'http://cms/uploads/category_icon.png' (length=36)
我是这样打印的:
foreach($profile_picture as $row)
{
echo $row->UserID;
}
我正在使用 Codeigniter 框架。
请帮忙
我刚刚解决了我的问题。
我正在从以下模型中检索数据:
控制器:
$this->get_user_pictures($id);
型号:
$data['profile_picture'] = $this->profile_model->picture($id);
并返回数组 $data 而不是 $data['profile_picture']
现在可以用了,谢谢