I want this array
$passengers = array(
'adult' => 2,
'child' => 1,
'infant' => 1
);
to change like this. Create a sequence based on number of persons.
Array(
[adult] => Array(
[0] => 1
[1] => 2
)
[child] => Array(
[0] => 3
)
[infant] => Array(
[0] => 4
)
)
I'm stuck with this code
$seq=1;
foreach($passengers as $paxKey => $paxVal){
if($paxVal>1){
$pax[$paxKey][] = $seq;
$seq = $seq+$paxVal;
}else{
$seq=$paxVal+$seq;
$pax[$paxKey][] = $seq;
}
}
Any assistance is highly appreciated.