note 14361 rejected and deleted from function.preg-replace.php by zak

From: Date: Fri, 27 Jul 2001 21:26:20 +0000
Subject: note 14361 rejected and deleted from function.preg-replace.php by zak
Groups: php.notes 
Request: Send a blank email to php-notes+get-15954@lists.php.net to get a copy of this message
Just a warning. preg_replace() will trip you up if you try to use it on a string that has dollar amounts in it. Simple Example: $pricestr = "$49.95"; $str = "Hello, my price is <price>"; $str = preg_replace("/<price>/", $pricestr, $str); print($str); The output will be "Hello, my price is .95" instead of "Hello, my price is $39.95". This came up while I was trying to use PHPLIB templates on a page that had pricing information. PHPLIB uses preg_replace to replace template variables with their values so it was breaking...

« previous php.notes (#15954) next »