Today i will discuss how to remove special characters list array from string with help of
str_replace() function.Normally programmer are using regular expression to remove special character from string with help of
preg_replace() method is very id the special character is fixed,if escape character is configurable from config file then its very difficult that time you need to below method to escape characters from string.
Simple Example to Escape special characters in PHP
$value ="Hi, I am ~ parvez $ alam";
echo 'before = ' .$value;
//get escape string from config file separated with ':'
//ex - ~:$
echo $escapeChars = $config['escapeSequenceValidation'];
//explode string with delimiter
$arrEscapeChars = explode(':', $escapeChars);
//replace escape characters array values with null values
$value = str_replace($arrEscapeChars, '', $value);
echo 'after = '.$value;