FYI, commit #245 http://trac.agavi.org/trac.cgi/changeset/245 adds
this functionality.

Thanks,
--Bob

On 9/5/05, Johan Mjönes <[EMAIL PROTECTED]> wrote:
> Bob Zoller wrote:
>
> >Definitely interesting.  We probably would want to make it flexible
> >enough to handle any number constants on the same line.  (your code
> >makes us *more* flexible than we are, but that next step would "finish
> >out" the problem).  Feel free to modify it as necessary, or I'll take
> >a look when I get a free second and propose the solution to the list.
> >
> >
> Hi,
>
> this snippet allows replacement of any number of constants.
>
> This could be done cleaner by using the &count parameter, but since it's
> only available since PHP 5.1.0, I used a more backwards friendly solution.
>
>
> -----------------------------
>     public static function & replaceConstants ($value)
>     {
>
>         // needed for first loop
>         $newvalue = $value;
>
>         do
>         {
>             $value = $newvalue;
>             $newvalue = preg_replace_callback(
>                 '/\%(\w+?)\%/',
>                 create_function(
>                     '$match',
>                     '$constant = $match[1]; ' .
>                     'return (defined($constant) ? constant($constant) :
> "%".$constant."%");'),
>                     $value,
>                     1);
>
>         } while ($newvalue != $value);
>
>         return $value;
>
>     }
>
> -----------------------------
>
> Best Regards,
>
> Johan
>
> --
> Johan Mjönes
> Programmer
> Phone: +46 8 789 12 00
> Fax: +46 8 789 12 12
> Cell: +46 7 052 838 55
> E-mail: [EMAIL PROTECTED]
> Internet: www.ongame.com
>
>
> This e-mail (including attachments) is strictly confidential and intended 
> solely for designated recipient(s). It contains privileged and confidential 
> information. If you have received this e-mail in error, you must not 
> disseminate, copy, distribute or take any action in reliance on it. Please 
> notify us immediately and delete this e-mail and any attachments. Thank you.
>
> _______________________________________________
> agavi-dev mailing list
> [email protected]
> http://labworkz.com/cgi-bin/mailman/listinfo/agavi-dev
>
_______________________________________________
agavi-dev mailing list
[email protected]
http://labworkz.com/cgi-bin/mailman/listinfo/agavi-dev

Reply via email to