Re: replace value of array by key of array in string variable with pre

From: Date: Sat, 21 Aug 2004 17:54:15 +0000
Subject: Re: replace value of array by key of array in string variable with pre
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-194401@lists.php.net to get a copy of this message
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

« previous php.general (#194401) next »