fork(2) download
  1. <?php
  2.  
  3. // your code goes here
  4.  
  5. $array = array('x' => array('y' => array('z' => 20)));
  6.  
  7. $keys = array('x', 'y', 'z');
  8.  
  9.  
  10. // Start nesting new keys
  11. $cur = &$array;
  12. foreach($keys as $v){
  13. $cur = &$cur[$v];
  14. }
  15.  
  16. echo $cur;
  17.  
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
20