...

View Full Version : Checking for a single character



ACJavascript
12-14-2003, 11:58 PM
Hello,

Okay I need to know how the heck I can check a form field check to make sure it has a certain character in it....

For instance

if($Uname== ?????){
error("Sorry but you dont have the character");
}else{
error("YOU DO HAVE THE CHARACTER");

}

Any help would be greatly appreciated!

raf
12-15-2003, 12:39 AM
the regex way:


if (!ereg("[%]+", $Uname)) {
error("Sorry but you dont have the character");
} else {
error("YOU DO HAVE THE CHARACTER"); // at least one time
}


or the php strstr() function


if (!strstr($Uname, "%")) {
error("Sorry but you dont have the character");
} else {
error("YOU DO HAVE THE CHARACTER"); // at least one time
}

I seam to remember that the second one should be faster, but i'm not sure + you wount notice the difference.

ACJavascript
12-15-2003, 02:16 AM
Hey RAF It worked Perfectly thanks again!!! :thumbsup:

raf
12-15-2003, 09:29 AM
You're welcome. Glad you got it running.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum