note 62522 deleted from function.str-replace by bjori

From: Date: Thu, 02 Mar 2006 14:55:00 +0000
Subject: note 62522 deleted from function.str-replace by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-104709@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 (#104709) next »