I am familiar with pcre more then php's POSIX extension :)

and it is said that preg_match() is faster than ereg(), see php manual
for more info :)

function isValid($strData, $bIncludeAlpha=false, $bIncludeNumber=false)
{
     switch(true) {
         case $bIncludeAlpha && !$bIncludeNumber:
             $ptr = "/^[a-zA-Z]+/";
             break;
         case !$bIncludeAlpha && $bIncludeNumber:
             $ptr = "/^[0-9]+/";
             break;
         case $bIncludeAlpha && $bIncludeNumber:
             $ptr = "/^[a-zA-Z0-9]+/";
             break;
         default:
             return false;
     }
     return preg_match($ptr, $strData);
}


please add "default" statement:)

----
Ni Shurong <[EMAIL PROTECTED]>

MAIL : [EMAIL PROTECTED]
QQ   : 412844
MSN  : [EMAIL PROTECTED]
BLOG : http://blog.njmars.com/myhan/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to