str_replace: use multiple or array?

From: Date: Sat, 31 Jul 2004 03:24:00 +0000
Subject: str_replace: use multiple or array?
Groups: php.general 
Request: Send a blank email to php-general+get-192374@lists.php.net to get a copy of this message
Hi, I need to use a couple of str_replace's in one of my programs and would like to know which is more resource friendly: 1) having multiple str_replace one after another eg: $text = str_replace("orange", "apple", "$text"); $text = str_replace("black", "white", "$text"); $text = str_replace("girl", "guy", "$text"); $text = str_replace("woman", "man", "$text"); $text = str_replace("plant", "tree", "$text"); 2) by using an array eg: $bad = array("orange", "black", "girl", "woman", "plant"); $good = array("apple", "white", "guy", "man", "tree"); $text = str_replace($bad, $good, $text); Also, off topic, Anybody else getting a non delivery message from: MAILER-DAEMON@ rotonet.rsdb.nl Thanks, Mag ===== ------ - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail

« previous php.general (#192374) next »