To remove all non-alphanumeric characters from a string in PHP, you can use preg_replace function with regular expression. Here's an example code:
main.php139 chars4 lines
In the code above, preg_replace function searches for all non-alphanumeric characters ([^a-zA-Z0-9]) in the $string variable and replaces them with an empty string ''. The resulting string is stored back in $string variable and then printed to the screen.
gistlibby LogSnag