note 105003 deleted from function.str-replace by danbrown

From: Date: Fri, 22 Jul 2011 16:13:06 +0000
Subject: note 105003 deleted from function.str-replace by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-181793@lists.php.net to get a copy of this message
Note Submitter: dave dot haefliger at gmail dot com ---- If you find yourself getting the following error when specifying the number of replacements to make, the solution is all too simple. Fatal error: Only variables can be passed by reference in [filename] on line [line] The code that throws: <?php $replacedcontent = str_replace($search, $repleace, $subject, 1); ?> The problem is the 4th parameter: as noted in the documentation str_replace is expecting it by reference. Simply change the code to: <?php $count = 1; $replacedcontent = str_replace($search, $repleace, $subject, $count); ?>

« previous php.notes (#181793) next »