$eventname = array(
"April" => array("April Fool", 4),
"May" => array("Labour Day", 1)
);
如何申请循环并打印数组元素?
答案 0 :(得分:0)
使用foreach遍历数组:
foreach($eventname as $event => $id) {
echo $event;
}
答案 1 :(得分:0)
您的活动日期需要用引号括起来。
$eventname = array(
"April"=>array("April Fool","4"),
"May"=>array("Labour Day","1")
);
foreach($eventname as $month => $event) {
Echo($month." ".$event['1']. " is ".$event['0']);
}
答案 2 :(得分:0)
你可以试试这个
foreach ($eventname as $key => $value) {
echo "Key: $key; <br />";
foreach ($value as $vale)
echo "Value is : $val <br />";
}