Re: regexp novice

From: Date: Fri, 18 May 2012 05:46:49 +0000
Subject: Re: regexp novice
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-317891@lists.php.net to get a copy of this message
Jim L. I did't actually consider that wide range of time values. Here is an update. Still this can be written without help of regex. I must add one more thing that a '00:01' is invalid in 12 hour format. OP wants it to be 12-hour format. function valid_time($time){ $m = substr($time, -2); $h = (explode(':', substr($time, 0, -2))); $h = $h[0]; return (is_numeric($h) && is_numeric($m) && $h>0 && $h<13 && $m>=0 && $m<60); } See the code in action here http://ideone.com/tSQIb -- Shiplu Mokaddim Talks: http://shiplu.mokadd.im Follow: http://twitter.com/shiplu Innovation distinguishes between follower and leader

« previous php.general (#317891) next »