I'm new to php programming, so sorry for any errors whatsoever.
I have a $monthsKeys variable that contains an array going from 0 to 12. I have another array ($Months) that contains 12 months from December to January.
I'm trying to create a function that takes the array as parameter and gets the key value from $monthsKeys so that it can return the month's name contained in $Months.
function getnomMois($monthsKeys){
$monthName= array(['Decembre','Novembre','Octobre','Septembre','Aout','Juillet','Juin','Mai','Avril','Mars','Fevrier','Janvier']);
foreach($monthsKeys as $monthName){
$monthName[] = $monthKeys['numMois'];
}
}
What I expect the function to return:
Instead of 12 for the month's number it returns December
What I'm trying to do:
I try to get the key from the $monthsKeys array and use it to get the value from the $MonthName array
What I understand I need to do:
I must extract the key value from the 1rst array and use it to get the value of the 2nd array accordin to the 1rst array key.
ie: monthKey[12] shoudl allow me to return monthName[12]='December'.