How to remove special characters in the string using php.This example it shows how to remove special characters from a string using regular expressions of php.
1 2 3 4 5 6 7 8 9 10 11 |
<?php $string = 'Lorem ipsum 46=75dolor 45 Ggfd$#2sit am/et, cons^&*ect+etuer ad(ip)isci_ng el+it.'; $formattedString = preg_replace('#[^\w()/.%\-&]#'," ", $string); echo $formattedString; // Output //Lorem ipsum 4675dolor 45 Ggfd2sit amet cons&ectetuer ad(ip)isci_ng elit. ?> |