I want to apply a regex to find the English month when i search for the month string in Spanish or other idiom. Currently i have an array of possible matches:
$monthsIdioms = array(
'en' => array('jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'),
'es' => array(
'/ene/',
'/feb/',
'/mar/',
'/abr/',
'/may/',
'/jun/',
'/jul/',
'/ago/',
'/sep/',
'/oct/',
'/nov/',
'/dic/'
));
But my date variable can have this format:
$date = "24 ene 15:45";
Or this one:
$date = "24 enero 15:45";
So i need a regex to find ene or enero in my date and with the other months:
'es' => array(
'/ene|enero/',
'/feb|febrero/',
'/mar|marzo/',
'/abr|abril/',
'/may|mayo/',
'/jun|junio/',
'/jul|julio/',
'/ago|agosto/',
'/set|septiembre/',
'/oct|octubre/',
'/nov|noviembre/',
'/dic|diciembre/'
)
And i call this with:
preg_replace($monthsIdioms['es'], $monthsIdioms['en'], $date);
but regex | is not properly working. What i am dong wrong?
Note that 'es' array is regex strings.
So to clarify this, i want that if i have this date: "24 ene 15:45" or this: "24 enero 15:45" to get converted to: "24 jan 15:45" the same with with any other month of the year: "24 ago 15:45" or "24 agosto 15:45" to "24 aug 15:45".
Well since all short names of the month are inside the actual name of the month you could just add a space: