|
Posted by davranfor on 10/18/07 11:49
On 18 oct, 13:44, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
> On Thu, 18 Oct 2007 10:42:20 +0200, <davran...@gmail.com> wrote:
> > Same but numbers can't be lesser than the previous number, must be
> > equal or greater, is this possible with regex??
>
> > 0-45-90-120 -> Valid
> > 0-45-45-90 -> Valid
> > 0-90-45-120 -> Invalid
>
> Maybe it's possible. I wouldn't do it with a regex anymore though.
>
> function _my_validate($string){
> $array = explode('-',$string);
> if(!is_array($array)) return false;
> $previous = 0;
> foreach($array as $value){
> if(
> intval($value)!= $value
> ||
> $value < $previous
> ||
> $value > 999
> ) return false;
> $previous = $value;
> }
> return true;
>
> }
>
> --
> Rik Wasmus
ok , thanks again
Navigation:
[Reply to this message]
|