View Full Version : Multiple Replaces

10-20-2004, 08:21 PM
I am trying to replace multiple strings on the same page but having problems. Only one seems to work... is there another function for this?

$row[0] = str_replace("&","and",$row[0]);
$row[0] = str_replace("/","or",$row[0]);

Also, I need it to put everything back to normal on the next page.

$row[0] = str_replace("and","&",$row[0]);
$row[0] = str_replace("or","/",$row[0]);

10-20-2004, 08:33 PM
Just create two arrays with the complementary values. like

$symbol = array('&', '/', '@');
$word = array('and', 'or', 'at');

and then you can do

$row[0] = str_replace($symbol, $word, $row[0]);

and back

$row[0] = str_replace($word, $symbol, $row[0]);

10-20-2004, 08:59 PM
That did the trick...
Thank you :D

10-20-2004, 09:04 PM
That did the trick...
Thank you :D
You're welcome

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum