note 90495 deleted from function.ereg by danbrown
| From: | danbrown@php.net | Date: | Fri, 24 Apr 2009 23:47:23 +0000 |
| Subject: | note 90495 deleted from function.ereg by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-153700@lists.php.net to get a copy of this message | ||
Note Submitter: yerko at altavoz dot net
----
In reply to pascalaschwanden:
Hi, for date validation use checkdate($mm, $dd, $yyyy) php function, plus an regexp for split values
from input string, for example:
<?php
if (!empty($input_value)) {
$ret = false;
// aaaa-/mm-/dd
if (preg_match('/^([0-9]{4})(\/|-)([0-9]{2})(\/|-)([0-9]{2})$/', $input_value,
$regs))
$ret = checkdate($regs[3], $regs[5], $regs[1]);
// dd-/mm-/aaaa
if (preg_match('/^([0-9]{2})(\/|-)([0-9]{2})(\/|-)([0-9]{4})$/', $input_value,
$regs))
$ret = checkdate($regs[1], $regs[3], $regs[5]);
return $ret;
}
?>
regards,
Yerko Chapanoff
http://www.linkedin.com/in/chapanoff