In this article, we will learn how to remove special characters from a string in PHP.
Create file index.php and put the following code
<?php $string = "text ! has \\ /allot # of % special % %*$&#*( characters"; $result = preg_replace('/[^a-zA-Z0-9_ -]/s', '', $string); echo $result; ?>
text has allot of special characters