I have a string of 2011-03-06
.
How do I extract the hyphen-separated values into individual variables:
$day = "06";
$month = "03";
$year = "2011";
You can use explode()
to separate the elements, and list()
to assign them to three separate variables.
list($year, $month, $day) = explode('-', $date);