Re: Strings and regular expression?

From: Date: Fri, 07 Feb 2003 23:19:10 +0000
Subject: Re: Strings and regular expression?
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-134828@lists.php.net to get a copy of this message
This one time, at band camp, "1LT John W. Holmes" <holmes072000@charter.net> wrote: > > Very true, I agree. For your solution, though, wouldn't it correctly match a > string such as '2,3,11,12' even though there is no entry that's just one? Ok, why not something like this.. There is almost always a better solution than regex <?php $string = '98,244,9,243,2,6,36,3,111,'; if(catchOne($string) == 'TRUE'){ echo 'Found a One'; }else{ echo 'No match found'; } function catchOne($string){ $arr = explode(',', $string); // check if the 1 is in the array if(in_array('1', $arr)){ return TRUE; }else{ return FALSE; } } ?> Kevin -- ______ (_____ \ _____) ) ____ ____ ____ ____ | ____/ / _ ) / _ | / ___) / _ ) | | ( (/ / ( ( | |( (___ ( (/ / |_| \____) \_||_| \____) \____) Kevin Waterson Port Macquarie, Australia

« previous php.general (#134828) next »