Hi Guy and Gay ?
I have the following code supposed to transform date format like this 04 desambra 1975
into 1975-12-04.
User can use whatever language he want like french, english, malagasy even Bichlamar-
for example : 04, otis 1975 = 04 aout 1975 = 04 aogositra 1975 = 04-ao�t 1975 = 04
august 1975 = 04 aug 1975 and the function must return 1975-08-04
It work perfectly and I'm really happy while I don't use minus (-) and If I use it,
the function stop working.
So how can I use minus in the regular expression ?
function my_date($birthday) {
$birthday = strtolower($birthday) ;
$array_search2 = array(
"'[���������]'i",
"'[�����]'i",
"'[�����]'i",
"'[����]'i",
"'[�����]'i") ;
$array_replace2 = array("a", "e", "u", "i", "o") ;
$array_search = array("'jan[a-zA-Z]{0,10}'i",
"'fe[vb]{1}[a-zA-Z]{0,10}'i",
"'m[a]{1,2}r[a-zA-Z]{0,10}'i",
"'a[vp]{1}r[a-zA-Z]{0,10}'i",
"'ma[iy]{1}[a-zA-Z]{0,10}'i",
"'j[ou]{1}n[a-zA-Z]{0,10}'i",
"'j[uo]{1}l[a-zA-Z]{0,10}'i",
"'[ao]{1}[out]{1}[a-zA-Z]{0,10}'i",
"'sept[a-zA-Z]{0,10}'i",
"'o[ck]{1}t[a-zA-Z]{0,10}'i",
"'n[o]{1,2}v[a-zA-Z]{0,10}'i",
"'de[sc]{1}[a-zA-Z]{0,10}'i"
) ;
$array_replace = array( "01", "02", "03", "04", "05", "06",
"07","08","09","10", "11", "12" ) ;
$birthday = preg_replace($array_search2, $array_replace2, $birthday) ;
$birthday = eregi_replace("([0-9]{1,2})[\-_:\|/, ]+([a-zA-Z0-9]{1,})[\-_:\|/,
]+([0-9]{2,4})","\\3-\\2-\\1", $birthday) ;
$birthday = preg_replace($array_search, $array_replace, $birthday) ;
return $birthday ;
}
echo my_date("12, janoary- 2001") ;
// return 12, 01- 2001 (bad)
and
echo my_date("12, januaari,\\__ 2001") ;
return exactly what I want ie 2001-01-12