php - return data using variable variables -


$raw_data = array ('data' => array ('id' => 'foo')); $fields = array ('id_source' => "data['id']");   foreach ($raw_data $data) {     foreach ($fields $key => $path) {         var_dump ($data['id']);         var_dump ($$path);     } } 

the first var_dump gives me correct value of foo. however, second 1 gives me undefined variable: data['id']. can tell me why case, since first var_dump worked confirming variable $data['id'] set.

i realized example basic , $data[$key] , change $fields = array ('id_source' => 'id'); want able go deeper multidimensional arrays when needed. why i'm trying original approach.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -