Re: Parsing Variables Inside a String

From: Date: Wed, 15 Aug 2007 15:45:54 +0000
Subject: Re: Parsing Variables Inside a String
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-260857@lists.php.net to get a copy of this message
heavyccasey@gmail.com 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

« previous php.general (#260857) next »