Re: [PHP] Expand Variables in String

2009-07-29 Thread Jonathan Tapicer
On Wed, Jul 29, 2009 at 6:47 PM, Daniel Kolbo wrote: > Jonathan Tapicer wrote: >> Use eval, like this: >> >> eval('$str_expanded = "' . str_replace('"', '\\"', $str) . '";'); >> >> The str_replace is used because you could have a " inside $str and it >> would break the string, if you are sure the $

Re: [PHP] Expand Variables in String

2009-07-29 Thread Daniel Kolbo
Jonathan Tapicer wrote: > Use eval, like this: > > eval('$str_expanded = "' . str_replace('"', '\\"', $str) . '";'); > > The str_replace is used because you could have a " inside $str and it > would break the string, if you are sure the $str has no " inside you > can omit it. > > Jonathan > > O

Re: [PHP] Expand Variables in String

2009-07-29 Thread Jonathan Tapicer
Use eval, like this: eval('$str_expanded = "' . str_replace('"', '\\"', $str) . '";'); The str_replace is used because you could have a " inside $str and it would break the string, if you are sure the $str has no " inside you can omit it. Jonathan On Wed, Jul 29, 2009 at 5:43 PM, Daniel Kolbo w

[PHP] Expand Variables in String

2009-07-29 Thread Daniel Kolbo
Hello, Is it possible to force a string to expand variable names after the string has been set and before the variable's been defined without having to do a string replace or preg_replace? for example, "; $var = "Variable Contents"; echo $str.""; $str_expanded = $str;//would like this to expand $