Ni Shurong wrote:

I did not test it:)

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;
    }
    return preg_match($ptr, $strData);
}



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

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

Thanx, seems to work just fine.

Some questions:
Why "true" in the switch()?
Why preg_match instead of ereg?

Regards,
J

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



Reply via email to