Hi,
I'm trying to do the following:
$ar = array("foo", "bar", "test", "echo $var;", "bla");
But of course the array then does not contain the value of $var, but instead "echo $var;". Is there a way to execute php code within an array?
Thanks!
if you want the value of the variable $var to be in the array, then you just need to do:
$ar = array("foo", "bar", "test", $var, "bla");
Okay, actually I gave a bad example. Well, I want to execute a for-loop in the array ... is it possible?
Thanks
user eval(). I.e.;
$x = array('test'=>'for ($x = 0; $x < 10; $x++) print $x;'); eval($x[test]);
Outputs 0123456789, as expected 🙂