Created
May 1, 2010 06:57
-
-
Save bhattisatish/386112 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parse_to_date_and_string($parse) { | |
$exclude = array('i', 'at'); | |
$parse_array = explode(" ", $parse); | |
$date = array(); | |
$data['text'] = array(); | |
$word_count = count($parse_array); | |
for($i = 0; $i < $word_count; $i++) { | |
if (strtotime($parse_array[$i]) > 0 && !in_array($parse_array[$i], $exclude)) { | |
$date[] = $parse_array[$i]; | |
} else { | |
$data['text'][] = $parse_array[$i]; | |
} | |
} | |
$data['date'] = strtotime(implode(" ", $date)); | |
return $data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment