note 95430 deleted from function.preg-quote by danbrown

From: Date: Mon, 04 Jan 2010 16:04:47 +0000
Subject: note 95430 deleted from function.preg-quote by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-164617@lists.php.net to get a copy of this message
Note Submitter: cory dot mawhorter at ephective dot com ---- preg_quote wasn't escaping the hyphen. According to a previous comment, this is a bug that has been fixed as of 5.3. Here is a function that fixes it: <?php function regex_quote ($str, $delim='/') { $quoted = preg_quote($str, $delim); if ( version_compare(PHP_VERSION, '5.3.0', '<') ) $quoted = str_replace('-', '\\-', $quoted); return $quoted; } ?>

« previous php.notes (#164617) next »