note 62520 added to function.str-replace

From: Date: Thu, 02 Mar 2006 13:53:11 +0000
Subject: note 62520 added to function.str-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-104702@lists.php.net to get a copy of this message
<?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 . '";'); } ?> ---- Server IP: 195.114.128.28 Probable Submitter: 195.140.179.210 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.str-replace.php Edit -- http://master.php.net/note/edit/62520 Del: integrated -- http://master.php.net/note/delete/62520/integrated Del: useless -- http://master.php.net/note/delete/62520/useless Del: bad code -- http://master.php.net/note/delete/62520/bad+code Del: spam -- http://master.php.net/note/delete/62520/spam Del: non-english -- http://master.php.net/note/delete/62520/non-english Del: in docs -- http://master.php.net/note/delete/62520/in+docs Del: other reasons-- http://master.php.net/note/delete/62520 Reject -- http://master.php.net/note/reject/62520 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#104702) next »