[PHP] dynamic variable headache
My newbie brain is maxed out on this, and I'm sure one of you more experience guys can quickly straighten me out. I've got a variable: $_mmdd = a_date_value; Later, I've got four variables; $foo= _; $bar=; $bleh=mm; $doh=dd; I want to stick these variables together on the fly to get _mmdd and use that value as a variable name to return a_date_value. It would be the equivalent of, echo $foo$bar$bleh$doh; That would give me a_date_value I've read the docs on dynamic variables but still can't seem to break through mentally on this one. Can you clear this up for me? Thanks in advance. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] dynamic variable headache
Robert, try reading about arrays instead. Variable variables are not a good idea to use because your code would soon become such a mess that one year later you will hate yourself seeing the code sputting frequently onto the monitor and making crosses of your fingers as to the Satan's appearance. Arrays can do it all. Variable variables are only needed in really, really few occasions. www.php.net/array -- Maxim Maletsky [EMAIL PROTECTED] ROBERT MCPEAK [EMAIL PROTECTED] wrote... : My newbie brain is maxed out on this, and I'm sure one of you more experience guys can quickly straighten me out. I've got a variable: $_mmdd = a_date_value; Later, I've got four variables; $foo= _; $bar=; $bleh=mm; $doh=dd; I want to stick these variables together on the fly to get _mmdd and use that value as a variable name to return a_date_value. It would be the equivalent of, echo $foo$bar$bleh$doh; That would give me a_date_value I've read the docs on dynamic variables but still can't seem to break through mentally on this one. Can you clear this up for me? Thanks in advance. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] dynamic variable headache
My newbie brain is maxed out on this, and I'm sure one of you more experience guys can quickly straighten me out. I've got a variable: $_mmdd = a_date_value; Later, I've got four variables; $foo= _; $bar=; $bleh=mm; $doh=dd; I want to stick these variables together on the fly to get _mmdd and use that value as a variable name to return a_date_value. It would be the equivalent of, echo $foo$bar$bleh$doh; That would give me a_date_value I've read the docs on dynamic variables but still can't seem to break through mentally on this one. Can you clear this up for me? $s = $foo . $bar . $bleh . $doh; echo $$s; //will give you a_date_value ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php