note 62520 deleted from function.str-replace by nlopess

From: Date: Mon, 06 Mar 2006 19:00:17 +0000
Subject: note 62520 deleted from function.str-replace by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-104924@lists.php.net to get a copy of this message
Note Submitter: alexander (yanovets at ukr dot net) ---- <?php /** * Emulates run-time behaviour of php double quotes processing. * For example if we have string '$var1 $var2 $var1' * and array('var1' => 'To Be', 'var2' => 'Or Not') the result of calling * this function will be 'To Be Or Not To Be'. * * @param string $str * @param array $array * @return string */ function str_multi_replace($str, &$array) { foreach ($array as $key => $value) { $$key = $value; } $str = str_replace('\\', '\\\\', $str); // for security $str = str_replace('"', '\"', $str); // for security return eval('return "' . $str . '";'); } ?>

« previous php.notes (#104924) next »