PHPRecent Posts

PHP remove special characters in the string

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.

 
$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.

What's your reaction?

Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0

Comments are closed.

Next Article:

0 %