What is a better way of doing the the below. Is there some function where i can specify/add keys to my array while splitting
<?php
$str = '2014-02-01';
$darray = explode('-',$str);
$final_array = array(
'year' => $darray[0],
'month' => $darray[1],
'day' => $darray[2],
);
?>
Y-m-dto, sayd-m-Y). Use DateTime class to create a DateTime object, and use that to get the year, month, and day.$date = strtotime($str); $final_array['day'] = date('d', $date);