Revision: 41063
Updated Code
at February 11, 2011 09:58 by robertdotim
Updated Code
<?php function validate_alphanum($string) { $count = 0; preg_replace("/[^a-zA-Z0-9]/", "", $string, -1, $count); if($count != 0) { return false; } return true; } ?>
Revision: 41062
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 11, 2011 09:44 by robertdotim
Initial Code
<?php function validate_alphanum($string) { $count = 0; preg_replace("/[^a-zA-Z0-9]/", "", $string, -1, $count); if($count != 0) { return false; die(); } return true; } ?>
Initial URL
http://robert.im
Initial Description
This function uses the preg_replace counter to check for any non-alphanumeric characters. You can use this for username / password validation if you don't want any special characters to be used.
Initial Title
Validate an alphanumeric string
Initial Tags
php
Initial Language
PHP