Re: VB-->PHP
| From: | Jay | Date: | Thu, 29 Jul 2004 10:48:44 +0000 |
| Subject: | Re: VB-->PHP | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-192170@lists.php.net to get a copy of this message | ||
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 <srni@gzlinux.org>
MAIL : srni@gzlinux.org
QQ : 412844
MSN : nsr_xh@hotmail.com
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