Thanks for that piece of code. I had searched but failed to come up with anything useful.
I've tried it but have not had any luck.
This is what i used to test:
function checkApostrophes(&$strQuery) {
//Remove white space
$strQuery = trim($strQuery);
$params = split(",", $strQuery);
$buffer = "";
foreach($params as $param) {
$param = trim($param);
if (substr_count($param, "'") > 0) {
//replace double all quotes in data
$param = substr($param, 0, strpos($param, "'"))."'".str_replace("'", "''", substr( $param, strpos($param, "'") + 1, -1 ))."'";
}
$buffer .= $param.", ";
}
//remove final "," and "\"s
$strQuery = str_replace("\\", "", substr($buffer, 0, -2));
}
$string1 = 'Ty\'r Ysgol';
$string2 = "Ty'r Ysgol";
$string3 = checkApostrophes($string1);
$string4 = checkApostrophes($string2);
echo $string3;
echo '<br />';
echo $string4;
This does not return anything.
All I need to do is remove single quotes. Is there an easier way?
BTW: white space in code - good or bad?
$string = 'First line';
$string = 'Third line';
Thanks,
Mei