Re: VB-->PHP

From: Date: Thu, 29 Jul 2004 10:57:56 +0000
Subject: Re: VB-->PHP
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-192171@lists.php.net to get a copy of this message
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 <srni@gzlinux.org> MAIL : srni@gzlinux.org QQ : 412844 MSN : nsr_xh@hotmail.com BLOG : http://blog.njmars.com/myhan/

« previous php.general (#192171) next »