Re: Parsing Variables Inside a String

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



heavyccasey@xxxxxxxxx wrote:
Hi, is there a function that can parse variables within a string?

For example:

$good_day = 'The';
$fr['iop'] = "y're crazy!";

$new = '$good_day$fr['iop']';
echo TheFunctionIRequest($new); // They're crazy!

Thanks!


One thing to add to what everybody else is saying, is that you should use curly braces around your variable names. This way the parser will not get confused.

$new = "{$good_day}{$fr['iop']}";

It just helps the parser recognize the beginning and ending of your variables.

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux