Re: replace value of array by key of array in string variable with pre g_replace()
| From: | Jason Wong | Date: | Mon, 26 Jul 2004 07:09:34 +0000 |
| Subject: | Re: replace value of array by key of array in string variable with pre g_replace() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-191868@lists.php.net to get a copy of this message | ||
On Monday 26 July 2004 10:09, Turbo wrote:
> 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?
I'm not sure what you're trying to do. Could you elaborate? In particular
where does preg_replace() fit in?
It seems you want $strValue to be "I am My Computer,build version 1.0\n". If
so:
1) you have completely misunderstood what preg_replace() is for
2) Use:
$strValue="I am {$message['name']},build version
{$message['version']}\n";
3) see manual > Types > Strings > 'Complex syntax'
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
A woman without a man is like a fish without a bicycle.
Therefore, a man without a woman is like a bicycle without a fish.
*/