[Solved] PHP arrays, getting to loop index information


I’m making an assumption about the true layout of your array, the following will create a $weekDays array to map an integer and a day of the week (I define the keys so you can shift them at any time):

$weekDays = (1=>'Monday', 2=>'Tuesday', 3=>'Wednesday', 4=>'Thursday', 5=>'Friday', 6=>'Saturday', 7=>'Sunday');

// loop through each week-day in the array
foreach ($myarray as $weekDay => $dates) {
    // loop through each "movie date" in the current week-day block
    foreach ($dates as $monthDate => $movies) {
        // output the day-of-the-week and the date-of-the-month
        echo $weekDays[$weekDay] . ' - ' . $monthDate . '<br />';

        // loop through all of the movies for the current date-of-the-month
        foreach ($movies as $movieTime => $movie) {
            // output the movie's time and name
            echo $movieTime . ' - ' . $movie . '<br />';
        }
    }
}

This is assuming the array in your example is really in the format:

$myarray = array(
    1 => array(
        13 => array(
            '15:00 - 16:20' => array(
                'Movie' => 'Batman'
            ),
            '18:10 - 19:30' => array(
                'Movie' => 'Misery'
            )
        ), // ... can repeat
    ), // ... can repeat
);

0

solved PHP arrays, getting to loop index information