Sounds like you almost knew what you wanted to do already, you basically defined it as a regex.
preg_replace("/[^A-Za-z0-9 ]/", '', $string);
More Related Contents:
- Find a match pattern of any digit and space with any character in a string and replace with | in PHP [closed]
- Remove new lines from string and replace with one empty space
- How to remove accents and turn letters into “plain” ASCII characters? [duplicate]
- Capturing text between square brackets in PHP
- Remove multiple whitespaces
- How do I remove all specific characters at the end of a string in PHP?
- How to mimic Stack Overflow Auto-Link Behavior
- Remove control characters from PHP string
- How to split a string by multiple delimiters in PHP?
- PHP remove special character from string
- Split camelCase word into words with php preg_match (Regular Expression)
- How to split a long string without breaking words?
- Php – regular expression to check if the string has chinese chars
- PHP – Add link to a URL in a string
- Get last whole number in a string
- Close open HTML tags in a string
- Regex & PHP – isolate src attribute from img tag
- Remove accents without using iconv
- Remove all non-numeric characters from a string; [^0-9] doesn’t match as expected
- How to prefix a positive number with plus sign in PHP
- How to remove numbers from a string with RegEx
- How to validate that a string only contain lowercase letters?
- Regex to match an IP address [closed]
- Split a comma-delimited string into an array?
- Why does PHP consider 0 to be equal to a string?
- Replacing accented characters php
- What is the most efficient way to count all the occurrences of a specific character in a PHP string?
- How do I replace double quotes with single quotes
- PHP regular expression to match lines starting with a special character
- Limit String Length