Re: [PHP] str_replace: use multiple or array?
* Thus wrote PHP Gen: > 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"); > ... > > 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); #2 Anytime you can have the internals of php handle stuff for you the better it most likely will be. > > > Also, off topic, > Anybody else getting a non delivery message from: > MAILER-DAEMON@ rotonet.rsdb.nl I'll see what I can do about this. thanks for reminding me :) Curt -- First, let me assure you that this is not one of those shady pyramid schemes you've been hearing about. No, sir. Our model is the trapezoid! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] str_replace: use multiple or array?
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php