rendered paste body protected function checkIfInLiteral($position, $line) { $literal = false; // Set flag that we are not currently in a string literal. $escapes = 0; for ($i = 0; $i < $position; $i++) { // If we encounter a string literal, skip over it. if (($line[$i] == "'" || $line[$i] == '"') && ($escapes % 2 == 0)) { $literal = true; for ($j = $i + 1; $j <= $position; $j++) { if ($line[$j] == '\\') { $escapes ++; } else { $escapes = 0; } if (($line[$j] == $line[$i]) && ($escapes % 2 == 0)) { $literal = false; $escapes = 0; break; } } $i = $j; } } return $literal; }