note 46661 deleted from function.str-replace by sean

From: Date: Tue, 19 Oct 2004 16:18:02 +0000
Subject: note 46661 deleted from function.str-replace by sean
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-78768@lists.php.net to get a copy of this message
Note Submitter: Daniellehr [~at~] gmx [~dot~] de ---- If you have got an array like <?php $array = array( 'Peter' => 'Thomas (old name: Peter)', 'Anne' => 'Deborah (old name: Anne)', 'Julia' => 'Maria (old name: Julia)', 'Jona' => 'Joseph (old name: Jona)' ); ?> And you want to replace Peter with Thomas, Anne with Deborah and so on, you can use: <?php $string = 'Julia loves Peter but he loves Anne and Jona loves Julia'; $string = str_replace(array_keys($array), $array, $string); // output: echo $string; ?> It works fine. Have fun ---- Reason: useless note

« previous php.notes (#78768) next »