note 23541 modified in function.ereg-replace by maxim
| From: | maxim@php.net | Date: | Tue, 06 Aug 2002 03:35:09 +0000 |
| Subject: | note 23541 modified in function.ereg-replace by maxim | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-34372@lists.php.net to get a copy of this message | ||
Be careful with replacing a substring with an int:
$rep = 2;
echo ereg_replace("two", $rep, "one two three");
/** output: "one three" **/
echo ereg_replace("two", "".$rep."", "one two three");
/** output: "one 2 three" **/
-> You have to convert an int to a string before replacing:
-> echo ereg_replace("two", (string) $rep, "one two three");
-> /** output: "one 2 three" **/
--was--
Be careful with replacing a substring with an int:
$rep = 2;
echo ereg_replace("two", $rep, "one two three");
/** output: "one three" **/
echo ereg_replace("two", "".$rep."", "one two three");
/** output: "one 2 three" **/
-> You have to convert an int to a string before replacing.
http://www.php.net/manual/en/function.ereg-replace.php