我想在数组内的数组内打印字符串,所以它看起来更像这样:
鲍勃:球、球棒、汽车
丹尼尔:蝙蝠、熊、汽车
不像这样:
Bob:数组([0] => 球 [1] => 球棒 [2] => 汽车)
丹尼尔:数组( [0] => 蝙蝠 [1] => 熊 [2] => 汽车)
<html>
<head>
<?php
$b;
$school=array(
"14"=>array("name"=>"Bob","toy"=>array("ball","bat","car")),
"23"=>array("name"=>"Daniel","toy"=>array("bat","bear","car")),
"31"=>array("name"=>"Tom","toy"=>array("bicycle","ball")),
"44"=>array("name"=>"Tim","toy"=>array("train","puzzle","ball","stick")),
"53"=>array("name"=>"Barbara","toy"=>array("bear", "car"))
);
foreach($school as $b)
{
echo $b["name"];
echo '<pre>';
print_r ($b["toy"]);
echo '</pre>';
}
?>
</head>
</html>
我尝试了很多东西,但我总是得到“字符串到数组转换”的错误。