note 119293 added to function.str-replace
| From: | (puregenius02@gmail.com) | 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