Jump to content

Checking string for alphaumeric


joecooper

Recommended Posts

Hi,

 

Im trying to check if this string only contains a-z A-Z and 0-9, but i am not sure it works

 

if(preg_match("/(A-Z][a-z][0-9]/", $payoutaddress)){
              echo("Address not valid!");
            }else{

}

 

It will always process the else. but even with other characters it will do the same

Link to comment
https://forums.phpfreaks.com/topic/245765-checking-string-for-alphaumeric/
Share on other sites

take this example.

 

<?php

$string = "abcd"; // the data you want to validate.

if(ctype_alnum($string)) // checking if the string contain alpha numeric characters.
{
echo "Success"; // do something what you want.
}
else {
echo "Error"; // do something.
}
?>

;

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.