Yes trying to get this to work:

 $curline = preg_replace("/<yabb\s+(\w+)>/","$$1",$curline);

So for the current line I am looking for something like <yabb copyright> I
want to replace that with the contents of $copyright.

Can variable variables be used in regular expressions?

Jeff
----- Original Message -----
From: "Christopher William Wesley" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: "Jeff Lewis" <[EMAIL PROTECTED]>
Sent: Friday, November 16, 2001 10:38 PM
Subject: Re: [PHP] Question on variable variables


> On Fri, 16 Nov 2001, Jeff Lewis wrote:
>
> > What I need to do, however, is append a variable portion to a constant
prefix.  So I have a set of variables that are named $MYdog, $MYcat etc. and
I need to do
> >
> > $a = "dog"
> > ${"MY$a"} being the same as $MYdog
> >
> > Can this be done, and if so - how? I can't get it to work.
>
> So what you want is a base name with a vaiably-changing portion
> concatenated?  Gotcha!
>
> // you variable base name
> $myVarBase = "MY";
>
> $a = cat;
> $something1 = "This Var Likes Cats";
>
> $b = dog;
> $something2 = "This Var Likes Dogs";
>
> $myVarName1 = $myVarBase . $a;
> $myVarName2 = $myVarBase . $b;
>
> // The same as $Mycat = "This Var Likes Cats";
> ${$myVarName1} = $something1;
>
> // The same as $Mydog = "This Var Likes Dogs";
> ${$myVarName2} = $something2;
>
>
> g.luck
>         ~Chris                           /"\
>                                          \ /     September 11, 2001
>                                           X      We Are All New Yorkers
>                                          / \     rm -rf /bin/laden
>
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to