Skip to content

Instantly share code, notes, and snippets.

@keithmorris
Created November 27, 2012 15:58
Show Gist options
  • Save keithmorris/4155049 to your computer and use it in GitHub Desktop.
Save keithmorris/4155049 to your computer and use it in GitHub Desktop.
Strip non alphanumeric characters from a string
<?php
/*
Found here:
http://www.emanueleferonato.com/2006/07/27/strip-non-alphanumeric-characters-from-a-string-with-php/
*/
$string_to_be_stripped = "Hi, I am a string and I need to be stripped...";
$new_string = ereg_replace("[^A-Za-z0-9]", "", $string_to_be_stripped );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment