Turbo wrote:
Hi,

I have array variable and string variable.
I want to replace value of array by key of array in string variable with preg_replace().


Example :
$message=array(
'name'=>'My Computer',
'version'=>'1.0'
);
$strValue="I am $name,build version $version\n";

How's to replace?

Yingyos

Why preg_replace?

Just do extract($message); then you have vars from the keys:

$name ='My Computer';
and
$version = '1.0';

Then those vars are used in the $strValue var.

-Shawn

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to