Let's suppose I have this date: 2016-07-27
. What I want to achieve is:
$year = 2016;
$month = 07;
$day = 27;
What I have tried:
$year = preg_match("/^[^-]*/", "2016-07-27");
It returns:1
$month = preg_match("(?<=\-)(.*?)(?=\-)", "2016-07-27");
It returns:Warning: preg_match(): Unknown modifier '('
$year = ???
How can I extract the numbers between the dashes and store them into the variables below as shown above?