cgm225 Posted February 18, 2008 Share Posted February 18, 2008 What is the easiest way to strip out any NON alphanumeric characters from a string contained in a variable? Example: $string = "Hello!!!!!!!!##"; Link to comment https://forums.phpfreaks.com/topic/91794-easiest-way-to-strip-out-any-non-alphanumeric-characters-from-a-string/ Share on other sites More sharing options...
phpSensei Posted February 18, 2008 Share Posted February 18, 2008 <?php $string = "numbers 12345, and symbols !£$%^&"; $new_string = preg_replace("/[^a-zA-Z0-9s]/", "", $string); echo $new_string ?> Link to comment https://forums.phpfreaks.com/topic/91794-easiest-way-to-strip-out-any-non-alphanumeric-characters-from-a-string/#findComment-470106 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.