Jump to content

Validate characters in a string


aeboi80

Recommended Posts

I have a keyword string which I need to verify only contains the following character set

0123456789abcdefghijklmnopqrstuvwxyz

 

If it contains anything but 0123456789abcdefghijklmnopqrstuvwxyz then I need to mark it as invalid.

 

if ($keyword contains ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_+{}|":<>?/.,;'[]\=-){
   $Error_msg = "invalid keyword";
}

 

I don't really know much about preg_replace or similar functions...but I presume I would need to use something like that. 

 

I appreciate any guidance/examples.

Link to comment
https://forums.phpfreaks.com/topic/224044-validate-characters-in-a-string/
Share on other sites

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.