Archive

Posts Tagged ‘array’

PHP Variable Variables and Reference Arrays in Use

September 23rd, 2009 lococobra No comments
PHP Variable Variables and Reference Arrays in Use

Something I haven’t talked about a whole lot on here is that I’m actually a professional PHP developer. It’s my job, so usually I don’t mix work and online stuff. This is pretty cool though, so I want people to be able to find it if they’re trying to figure out how to do it. Be warned, if you’re not a PHP coder the following post will make ZERO sense to you :P

Before I get into what a “reference array” is (I made that term up) let me guide you through the discovery and some practical uses of the theory around references. A while ago I was looking for a way to do something in code that didn’t seem very possible. I wanted to do this:

$var1 = 'Hello World';
echo $"var1";

Problem is, that doesn’t work.. instead I found that you can use variable variables (also known as dynamic variables)
Read more…

Categories: PHP Magic Tags: , ,