Answers for "php check string for non alphanumeric characters"

PHP
28

php generate random alphanumeric string

function generateRandomString($length = 25) {
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $charactersLength = strlen($characters);
    $randomString = '';
    for ($i = 0; $i < $length; $i++) {
        $randomString .= $characters[rand(0, $charactersLength - 1)];
    }
    return $randomString;
}
//usage 
$myRandomString = generateRandomString(5);
Posted by: Guest on October-30-2019
0

text box should accept only alphanumeric not special characters in php

if(ctype_alnum($string)){
    echo "Yes, It's an alphanumeric string/text";
}
else{
    echo "No, It's not an alphanumeric string/text";
}
Posted by: Guest on September-21-2020

Code answers related to "php check string for non alphanumeric characters"

Browse Popular Code Answers by Language