Eric said:replace? No, but you can use www.php.net/str_replace
$string = "I'm not too good at PHP. Sadly, this kinda confuses me. Let's say I want to replace all instances of site1.com with site2.com. Exactly how would I write that out? This function seems to require 3 parameters...";
$string = str_replace(array('site1.com', 'site2.com'), '', $string);
Archangel said:I'm not too good at PHP. Sadly, this kinda confuses me. Let's say I want to replace all instances of site1.com with site2.com. Exactly how would I write that out? This function seems to require 3 parameters...
Eric said:PHP:$string = "I'm not too good at PHP. Sadly, this kinda confuses me. Let's say I want to replace all instances of site1.com with site2.com. Exactly how would I write that out? This function seems to require 3 parameters..."; $string = str_replace(array('site1.com', 'site2.com'), '', $string);
Ah, yes - it refers to what text you're wanting PHP to perform the replacements on.Archangel said:Looks good but I need to ask: What is $string referring to the top text? Is that the text that I want the script to look through & make the necessary replaces to? lol I know a little PHP but this is something outta my league.
Eric said:Ah, yes - it refers to what text you're wanting PHP to perform the replacements on.
Ah, good catch - I read it as he wanted to replace them both. :red:nasaboy007 said:is it just me or does $string = str_replace(array('site1.com', 'site2.com'), '', $string); just remove all instances of site1.com AND site2.com... i thought he said he had wanted to convert site1.com into site2.com?
in which case you'd have to do: $string = str_replace('site1.com', 'site2.com', $string);
nasaboy007 said:is it just me or does $string = str_replace(array('site1.com', 'site2.com'), '', $string); just remove all instances of site1.com AND site2.com... i thought he said he had wanted to convert site1.com into site2.com?
in which case you'd have to do: $string = str_replace('site1.com', 'site2.com', $string);


