Forum Moderators: coopster
-------------------------------------------------------------------
if (($row['height'] == "5\'0\" - 5\'4\"")¦¦($row['height'] == '5 - 5 4'))
{
$height = '1,50 - 1,65';
}
--------------------------------------------------------------------
When i echo $row['height'] it works without any problems and i think i got the problem with qoutes. But why don't it work when i use \" and \' ?
$string = 'Don\'t "escape" these doubles '." but you'd escape \"these.\"";
echo $string; // no \ in final output
$string = 'Don\'t \"escape\" everything '." because you\'ll get \"\\\" in your output.";
echo $string; // you end up with \ in output
Running this sample code should do a better job of showing why escaping both quote types is causing a problem in your code.
<?php
echo '<pre>';
$string = <<<___EOF
5'0" - 5'4"
___EOF;
if ($string == "5\'0\" - 5\'4\""){ // escaping all quote types
echo $string.' is equal to '."5\'0\" - 5\'4\"".PHP_EOL;
} else {
echo $string.' is not equal to '."5\'0\" - 5\'4\"".PHP_EOL;
}
if ($string == "5'0\" - 5'4\""){ // wrapped in double quotes, only escapes double quotes
echo $string.' is equal to '."5'0\" - 5'4\"".PHP_EOL;
} else {
echo $string.' is not equal to '."5'0\" - 5'4\"".PHP_EOL;
}
if ($string == '5\'0" - 5\'4"'){ // wrapped in single quotes, only escapes single quotes
echo $string.' is equal to '.'5\'0" - 5\'4"'.PHP_EOL;
} else {
echo $string.' is not equal to '.'5\'0" - 5\'4"'.PHP_EOL;
}
?>