I have a string date like this:
$date = "23/12/2011";//format: dd/mm/yyyy.
I need each part of this date in its own variable, so that $d=="23", $m=="12", and $y=="2011".
Any suggestions on how to do this would be appreciated...
I have a string date like this:
$date = "23/12/2011";//format: dd/mm/yyyy.
I need each part of this date in its own variable, so that $d=="23", $m=="12", and $y=="2011".
Any suggestions on how to do this would be appreciated...
You could just do:
list($day, $month, $year) = split("[/]", $yourDate);
split() is deprecated since it uses the POSIX regex engine, you should avoid it in favour for preg_split() (RegEx splitting with limited Unicode support), mb_split() for regex splitting with unicode support or explode() for regex-less splitting.The regex you're looking for is /(\d+)\/(\d+)\/(\d+)/ and in the preg_match they would be contained in the $matches array you define in the preg_match call.