note 92968 deleted from function.str-replace by philip

From: Date: Wed, 07 Oct 2009 07:53:32 +0000
Subject: note 92968 deleted from function.str-replace by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-161436@lists.php.net to get a copy of this message
Note Submitter: Ashus ---- I needed a function to replace the same string with values of an array. I'm using it to fill in some things after having it translated. <?php function replace_with_array($what, $with, $s) { $a = explode($what, $s); $s = ''; $c = count($a); for($i=0;$i<$c;$i++) {$s .= $a[$i].(($i+1<$c)?((isset($with[$i]))?$with[$i]:$what):'');} return $s; } echo replace_with_array('', array('<span>','</span>'), 'foobarraboof.'); ?>

« previous php.notes (#161436) next »