note 119293 added to function.str-replace

From: Date: Fri, 06 May 2016 10:28:19 +0000
Subject: note 119293 added to function.str-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-205434@lists.php.net to get a copy of this message
$myString = “It was the best of mine it was the worst of mine,”; // Displays “It was the best of bananas, it was the worst of bananas,” echo str_replace( “mine”, “bananas”, $myString ); If you want to know how many times the search string was replaced, pass in a variable as an optional fourth argument. After the function runs, this variable holds the number of replacements: $myString = “It was the best of mine, it was the worst of mine,”; // Displays “It was the best of bananas, it was the worst of bananas,” echo str_replace( “mine”, “bananas”, $myString, $num ) . “ < br/ > ”; // Displays “The text was replaced 2 times.” echo “The text was replaced $num times. < br/ > ”; ---- Server IP: 72.52.91.14 Probable Submitter: 119.154.63.114 ---- Manual Page -- http://php.net/manual/en/function.str-replace.php Edit -- https://master.php.net/note/edit/119293 Del: integrated -- https://master.php.net/note/delete/119293/integrated Del: useless -- https://master.php.net/note/delete/119293/useless Del: bad code -- https://master.php.net/note/delete/119293/bad+code Del: spam -- https://master.php.net/note/delete/119293/spam Del: non-english -- https://master.php.net/note/delete/119293/non-english Del: in docs -- https://master.php.net/note/delete/119293/in+docs Del: other reasons-- https://master.php.net/note/delete/119293 Reject -- https://master.php.net/note/reject/119293 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#205434) next »