关于php循环显示数组内容Undefined property:问题
print_r($array_Order);中看得到有结果Array([0]=>ordersObject([id]=>[menu_id]=>1[user]=>)[1]=>...
print_r($array_Order);中看得到有结果
Array
(
[0] => orders Object
(
[id] =>
[menu_id] => 1
[user] =>
)
[1] => Goods Object
(
[id] =>
[no] =>
[name] => 可乐
[picture] =>
[price] =>
[number] =>
[family] =>
)
[2] => orders Object
(
[id] =>
[menu_id] => 1
[user] =>
)
[3] => Goods Object
(
[id] =>
[no] =>
[name] => 可乐
[picture] =>
[price] =>
[number] =>
[family] =>
)
)
为什么还说Undefined property: orders::$name 和Undefined property: Goods::$menu_id
还有怎么改才会显示出来
include "Order.class.php";
$user = new User;
$contentStr = "";
$array_Order = $user->searchOrder($fromUsername);
for($i = 0; $i < count($array_Order);$i++)
{
$contentStr = $contentStr . $array_Order[$i]->menu_id . " " . $array_Order[$i]->name . "\n" ;
} 展开
Array
(
[0] => orders Object
(
[id] =>
[menu_id] => 1
[user] =>
)
[1] => Goods Object
(
[id] =>
[no] =>
[name] => 可乐
[picture] =>
[price] =>
[number] =>
[family] =>
)
[2] => orders Object
(
[id] =>
[menu_id] => 1
[user] =>
)
[3] => Goods Object
(
[id] =>
[no] =>
[name] => 可乐
[picture] =>
[price] =>
[number] =>
[family] =>
)
)
为什么还说Undefined property: orders::$name 和Undefined property: Goods::$menu_id
还有怎么改才会显示出来
include "Order.class.php";
$user = new User;
$contentStr = "";
$array_Order = $user->searchOrder($fromUsername);
for($i = 0; $i < count($array_Order);$i++)
{
$contentStr = $contentStr . $array_Order[$i]->menu_id . " " . $array_Order[$i]->name . "\n" ;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询