preg_quote — escapes regular expression characters
string preg_quote ( string $str [, string $delimiter = NULL ] )
preg_quote() takes the parameter str and adds a backslash before each character in the regular expression syntax. This is usually used when you have some runtime strings that need to be matched as regular expressions.
Regular expression special characters are: . + * ? [ ^ ] $ ( ) { } = ! < > | : -
Input string
If the optional parameter delimiter is specified, it will also be escaped. This is usually used to escape the delimiter used by the PCRE function. / is the most common delimiter.
Returns the escaped string.
preg_quote() example
$keywords = '$40 for a g3/400';
$keywords = preg_quote($keywords, '/');
echo $keywords; // Return $40 for a g3/400
?>