Hi guys:

I've looked through the documentation and didn't see anything like this;
please do let me know if this has been implemented/discussed previously.

I'm looking for a fast mechanism to do 'user-space' string expansion.
That is, given a key/value set $a and a string $b, i'd like for every
occurance of $key in $b to be expanded to $a[$key]. This in and of itself
it easy to do with preg_replace_callback() or eval().

Both of the above methods have their disadvantages, though (eval's being
the possibility of escape-style attacks, preg_replace_callback's being
having to fire up the regex engine). 

I'd like to propose a function var_expand($str [, $namespace]). It'd be
capable of using PHP's built-in variable expansion code in a controlled
manner - saving the need to do ad-hoc string replacement or eval()
blocks. I'm willing to bet it'd also be fast.

If I'm barking up the wrong tree or am completely missing something,
please let me know. Barring any immediate vetos, would it be appropriate
if I prepared a patch later this week?


Thanks in advance,
- Dave
  [EMAIL PROTECTED]


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to