I want to remove the following special character from my string.
:
'
""
`
``
how can i remove each of the above character from my string?
You could use preg_replace
$string = preg_replace('/[:'" `]/', '', $string);
Use str_replace:
$to_remove = array(':', "'", '"', '`'); // Add all the characters you want to remove here
$result = str_replace($to_remove, '', $your_string);
This will replace all the characters in the $to_remove array with an empty string, essentially removing them.
This is a more efficient solution than using preg_replace, which uses regular expressions:
$string = str_replace(array(':',"'",'"','`'), '', $sourceString);
You can read more about str_replace and preg_replace at the php docs: