For SQL Server, I need to replace an apostrophe with a double apostrophe. Is there a built in function that will do it?
Thank you...
Todd
/* Fix a string with a apostrophy */
function fix_string($string) {
for ($i=0;$i < strlen($string);$i++) {
if ($string[$i] == "'") $result = $result . "'";
$result = $result . $string[$i];
}
return $result;
}
Fix a string with an apostrophy
Moderator: General Moderators
Re: Fix a string with an apostrophy
Please use code tags when posting code.
Code: Select all
$str = str_replace("'", '"', $str);
Re: Fix a string with an apostrophy
Thanks...simple...slick.
I need to replace a single apostrophe with two apostrophes, but that is a simple change to what you gave (which is hard to see in the example below.
Todd
I need to replace a single apostrophe with two apostrophes, but that is a simple change to what you gave (which is hard to see in the example below.
Code: Select all
$str = str_replace("'", "''", $str);