Hello everyone,
I am trying to match a date in PHP using preg_match, split it and assign parts of it to an array, the date looks like "20100930", here is the code I am using:
// Make the tor_from date look nicer
$nice_from = $_POST['tor_from'];
$matches = array();
$ideal_from = '';
preg_match('/\d{4}\\d{2}\\d{2}\/', $nice_from, $matches, PREG_OFFSET_CAPTURE, 0);
// if (isset($matches[0])) $nice_from = $matches[0];
echo $matches[0];
echo "<br />";
echo $matches[1];
echo "<br />";
echo $matches[2];
echo "<br />";
echo $matches[3];
echo "<br />";
Ive been using: http://php.net/manual/en/function.preg-match.php and http://stackoverflow.com/questions/1179165/php-preg-match-question to formulate ideas on how to do this, however I have had no luck in getting it to work. Any help would be greatly appreciated.