Why does the following work for removing a \ before a single quote but not a double quote?
UPDATE: the code below works but not when the single ' or " iss in the first position. Is there a way to fix that?
Input is coming from a form where I have no control of what people type in.
$x[0] = $_POST['line1'];
$x[1] = $_POST['line2'];
$x[2] = $_POST['place'];
//check for apostrophes and quotes
for($i=0;$i<3;$i++){
while( strpos($x[$i], "\'") != false){
$pos = strpos($x[$i], "\'");
$x[$i] = substr_replace($x[$i],"",$pos,1);
}
while( strpos($x[$i], '\"') != false){
$pos = strpos($x[$i], '\"');
$x[$i] = substr_replace($x[$i],"",$pos,1);
}