Having a mental block....
I know this is so easy.... but nothing is going my way today!
Can anyone help me with a quick function to search a string and escape all apostrophes in php. Thanks.
Having a mental block....
I know this is so easy.... but nothing is going my way today!
Can anyone help me with a quick function to search a string and escape all apostrophes in php. Thanks.
Use str_replace:
$str = ...
$str = str_replace("'", "\\'", $str);
You can use:
$changed_string = str_replace("'","\\'",$input_string)
You can also make use of the library function addslashes. Remember it will add slashes in front of single quote ('), double quote ("), backslash () and NULL.