Dear list,

this is my first post to the PHP general list.

I have an issue with a variable variable 

My use case:

I have an array called $myArray. The structure is as following:

array(1) {
  array(1) {
    array(1) {
      array(5) {
        string(6) "red"

As you can see, the item_number_one has no direct color value assigned but the 
structure of the path to item_number_one in the $myArray variable. I tried with 
array_wal_resursive. During this step (the array building is completed) I want 
to find these values (I use a static value in my example, in the real code I 
will use regular expressions) and assign the value of the virtually related 
item to the considered item.

So in my example above, I want to have the following values after the process 
is done:

$myArray[user_interface][design][my_colors][item_mumber_one] = red; // this is 
item number 1
$myArray[user_interface][design][my_colors][item_mumber_two] = red; // this 
should be item number 2

The second issue here is, how do I evaluate at which point the process is 
exactly, because the value and the key that is transferred to the function by 
array_walk_recursive has only the value itself but not array path to the 
current item.

Any idea how get this done? Or am I too complicated maybe?

I tried several combinations of ${$var}, $myArray{$var}, {$myArray}{$var} ... 
and many more.

Any help is much much appreciated!

Merry X-mas greeting from Indianapolis

Cheers, Nils
-- / a Fractal project

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to