PHP variable variables

Thu, Feb 28, 2008

I always get stuck on one problem with PHP and that is referencing dynamically created array variables. Imagine I have an array of values, say country codes: 'uk,us,de,es' and I want to output data into array variables that have the name $array_countrycode.

It took me a while to get to the bottom of this, I knew it had something to do with Variable Variables but the documentation doesn't really cover this kind of example. Eventually I found the solution I was looking for:
more


alt=