How to Remove Special Character from String in PHP
some data that contains special characters (e.g. single quote, double quote. special characters removed from a string using the preg_replace function.
In this tutorial, I will inform you how to remove the special character from string in PHP. we want to remove all special characters from the string by using preg_replace. So, its function will remove any special character except letter and numbers.
1 2 3 4 5 6 7 8 | <?php $string="example?"; $data = preg_replace('/[^a-zA-Z0-9_ -]/s','',$string); echo $data; //output example ?> |
Please follow and like us: