I'm sorry, but I read both the php.net and Zend articles and comments on str_replace, but I just can't seem to understand it..
can anyone explain what goes into the parenthesis?
ie, mail() is mail(who its to, the message, the headers)
what would str_replace() be?
ThanKs
str_replace
Moderator: General Moderators
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
-
Cruzado_Mainfrm
- Forum Contributor
- Posts: 346
- Joined: Sun Jun 15, 2003 11:22 pm
- Location: Miami, FL
str_replace("what you look for","the substring that is going to replace 'what you look for'",$TheStringThatContainsEverything);
ie.:
good luck
ie.:
Code: Select all
<?php
$greeting = "Hi my name is John";
str_replace("Earl","John",$greeting);
echo $greeting; //will return: Hi my name is Earl
?>-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
What about replacing 's?
I have a variable called $varsign and I want to get rid of all the 's and change them to ' (the HTML number for them) so i dont get this:
"John's cat is very fast."
becomes
"John''s cat is very fast."
yet it seems to not replace it..
my code:
Thanks
I have a variable called $varsign and I want to get rid of all the 's and change them to ' (the HTML number for them) so i dont get this:
"John's cat is very fast."
becomes
"John''s cat is very fast."
yet it seems to not replace it..
my code:
Code: Select all
str_replace("'","'",$varsign);str_replace returns the new string with the replacements. So you have to assign it to something, usually the original string.
Code: Select all
$varsign = str_replace("'", ''', $varsign);- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
You don't need str_replace() to get rid of escape characters (the backslashes), use stripslashes() instead, or turn off magic_quotes in your php.ini.
Mac
Mac