jd2007 Posted July 11, 2007 Share Posted July 11, 2007 how do i replace two words in a string at the same time ? Link to comment https://forums.phpfreaks.com/topic/59442-solved-php-string-help/ Share on other sites More sharing options...
metrostars Posted July 11, 2007 Share Posted July 11, 2007 Using arrays and str_replace $old = array("Oldword1", "Oldword2"); $new = array("Newword1", "Newword2"); $newstring = str_replace($old, $new, $oldstring); Link to comment https://forums.phpfreaks.com/topic/59442-solved-php-string-help/#findComment-295358 Share on other sites More sharing options...
mosi Posted July 11, 2007 Share Posted July 11, 2007 <?php $original_text = "this is the original text"; $original_text = str_replace("original", "new", $original_text); echo $original_text; // Will echo "this is the new text" ?> Look at: http://www.php.net/str_replace for more information Link to comment https://forums.phpfreaks.com/topic/59442-solved-php-string-help/#findComment-295360 Share on other sites More sharing options...
jd2007 Posted July 11, 2007 Author Share Posted July 11, 2007 metrostars, thanks...u gave me the right answer ! Link to comment https://forums.phpfreaks.com/topic/59442-solved-php-string-help/#findComment-295382 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.