note 61298 deleted from function.str-replace by danbrown

From: Date: Sun, 20 Jul 2008 16:20:04 +0000
Subject: note 61298 deleted from function.str-replace by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-142174@lists.php.net to get a copy of this message
Note Submitter: vlatko dot surlan at RMVME gmail dot com ---- Suggested code has some drawbacks in the context of many replacement pairs (i am not suggesting that mine has none). The example code you provided: <?php return str_replace( array('&#262;', '&#263;', '&#264;', [...]), array('&#262;', '&#263;', '&#264;', [...]), strtoupper($string) ) ; ?> relies on the fact that visual identation is provided by all replacement elements beeing of the same width, which is hardly ever true in the real world (please correct me if I'm wrong). Another nasty feature is that this code extends to the right with addition of new elements while the solution provided in the earlier post extends in the driection of the natural flow of code, thus, retaining correct code width for all cases. Perhaps you have ommited the fact that I specifically intended suggested code format for cases with many replacement pairs indicated with /* many lines here */ in the previous post?

« previous php.notes (#142174) next »