Re: What am i doing wrong :\

From: Date: Mon, 12 May 2003 19:00:51 +0000
Subject: Re: What am i doing wrong :\
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-147332@lists.php.net to get a copy of this message
http://www.php.net/preg_match preg_match("/[regex]/",$str) On Mon, 2003-05-12 at 12:25, Clivus2k1@aol.com wrote: > Basicly its a simple to check to see if chars a-z,A-Z,0-9 and _ are added, > why does this tell me both strings display illegal chars? :\ > > <? > function validc($text) { > if (preg_match("[a-zA-Z0-9_]",$text)) { return 1; } > else { return 0; } > } > > $str = "moo-"; > if (!validc($str)) { echo("ERROR - $str contains illegal chars<br>"); } > > $str2 = "moo"; > if (!validc($str2)) { echo("ERROR - $str2 contains illegal chars"); } > ?> > > Thanks for the help in advanced :-) -- Michael Geier <mgeier@cdmsports.com>

« previous php.general (#147332) next »