note 14361 added to function.preg-replace.php

From: Date: Fri, 27 Jul 2001 17:37:56 +0000
Subject: note 14361 added to function.preg-replace.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-15947@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... http://www.php.net/manual/en/function.preg-replace.php

« previous php.notes (#15947) next »