Returns true if the inputed string is alphanumeric (either letters or numbers) after ignoring chosen chars.
The snippet makes use of str_replace and the original ctype_alnum.
Usage:
/*** With an array ***/
$IgnoreChars = array("!","_","-");
echo ctype_alnumi("Hello!World",$IgnoreChars); # Output: true
echo ctype_alnumi("Hello,World",$IgnoreChars); # Output: false
/*** With a String ***/
echo ctype_alnumi("Hello!","!"); # True
echo ctype_alnumi("Hello!","."); # False
echo ctype_alnumi("Hello!"); # False
echo ctype_alnumi("Hello"); # True
function ctype_alnumi($alnum=0,$ignore=null) {
if (!empty($ignore)) $alnum = str_replace($ignore,'',$alnum);
if (ctype_alnum($alnum)) return true;
else return false;
}
All I'm missing is finishing the documentation and I'm set for release :D
I'll send you a PM so i can show off mah skills ;)
(you can see the docu here http://moshcode.me/labs/msfDocs/ **unfortunately is in Portuguese )
Yep, the example usage doesn't show its true value :P
I'm using it to parse username registrations ^^