- array_values: documentation ( source)
- array_keys: documentation ( source)
<?php
$tourAvaibilityDate = array (
'tour_avaibility' =>
array (
'tour_avaibility_location' =>
array (
'Location_one' => 'Location_two',
'Location_seven' => 'Location_nine'
),
'tour_avaibility_date' =>
array (
'02/11/2020' => '02/17/2020',
'02/21/2020' => '02/26/2020'
)
)
);
$tours = $tourAvaibilityDate['tour_avaibility'];
$start_locations = array_keys($tours['tour_avaibility_location']);
$end_locations = array_values($tours['tour_avaibility_location']);
$start_dates = array_keys($tours['tour_avaibility_date']);
$end_dates = array_values($tours['tour_avaibility_date']);
$c = count($start_locations);
for ($i = 0; $i < $c; $i++) {
echo $start_locations[$i] . ' - ' . $end_locations[$i] . "\n";
echo $start_dates[$i] . ' - ' . $end_dates[$i] . "\n";
}