note 92933 added to function.str-replace
| From: | steve at slhawkins dot com | Date: | Sat, 15 Aug 2009 08:19:18 +0000 |
| Subject: | note 92933 added to function.str-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-159507@lists.php.net to get a copy of this message | ||
Something that might seem obvious, that had me searching the documentation for a different
function... if the text you're replacing looks like a variable i.e. $name. Make sure to use
single quotes..
str_replace("{$name}", 'Steve', $string);
will search the string for whatever the variable is set to, in my case it wasn't set at all...
str_replace('{$name}', 'Steve', $string);
Worked correctly as I was aiming for....
----
Server IP: 208.69.120.35
Probable Submitter: 98.24.228.49
----
Manual Page -- http://www.php.net/manual/en/function.str-replace.php
Edit -- https://master.php.net/note/edit/92933
Del: integrated -- https://master.php.net/note/delete/92933/integrated
Del: useless -- https://master.php.net/note/delete/92933/useless
Del: bad code -- https://master.php.net/note/delete/92933/bad+code
Del: spam -- https://master.php.net/note/delete/92933/spam
Del: non-english -- https://master.php.net/note/delete/92933/non-english
Del: in docs -- https://master.php.net/note/delete/92933/in+docs
Del: other reasons-- https://master.php.net/note/delete/92933
Reject -- https://master.php.net/note/reject/92933
Search -- https://master.php.net/manage/user-notes.php