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!!!!!!!!##"; Quote Link to comment 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 ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.