tags:

views:

28

answers:

1

Possible duplicate:
http://stackoverflow.com/questions/433302/php-convert-a-string-to-variable

for example:

$test = array("this","is","a","test");

$what_array_to_read = "$test[0]";

function to read the array $test[0]

+4  A: 

That is only possible using eval which should be avoided.

But if you do

$what_array_to_read = "test";
$what_index_to_read = 0;

then you can access

$$what_array_to_read[$what_index_to_read]; // will echo "this"
Pekka