如何使用 for 循环打印关联数组的元素?

How can I print the elements of an associative array with a for loop?

$eventname = array(
        "April" => array("April Fool", 4),
        "May" => array("Labour Day", 1)
    );

如何申请循环打印数组元素?

使用foreach遍历数组:

foreach($eventname as $event => $id) {
    echo $event;
}

您的活动日期需要用引号引起来。

$eventname = array(
  "April"=>array("April Fool","4"),
  "May"=>array("Labour Day","1")
);

foreach($eventname as $month => $event) {
  Echo($month." ".$event['1']. " is ".$event['0']);
}

你可以试试这个

 foreach ($eventname as $key => $value) {
         echo "Key: $key; <br />"; 
              foreach ($value as $vale)
              echo "Value is : $val <br />";
        }