note 50688 added to function.str-replace
| From: | somewhereinspace at deepspace dot com | Date: | Mon, 07 Mar 2005 13:33:44 +0000 |
| Subject: | note 50688 added to function.str-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-86039@lists.php.net to get a copy of this message | ||
This is an reply to Adam F-K's alphanumeric check:
I guess my function does the same, but a bit quicker
<?php
// Checks, if the String contains only allowed Chars
// edit the RegEx if you need other chars as well
// for example: [^A-Za-zóòöôúùüûéèêáàäâÓÒÖÔÜÚÙÛÁÀÂÄ .-]
// return true or false
function isAlphaNumeric( $str )
{
$len_org = strlen( $str );
$len_chk = strlen( ereg_replace( "[^A-Za-z0-9]", "", $str ) );
return $len_org == $len_chk;
}
?>
Ronald L.
----
Manual Page -- http://www.php.net/manual/en/function.str-replace.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+50688
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50688&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50688&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50688&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50688&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50688&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+50688&report=yes
Search -- http://master.php.net/manage/user-notes.php