[ create a new paste ] login | about

Link: http://codepad.org/FLIjICJj    [ raw code | output | fork ]

PHP, pasted on Dec 13:
<?php

$config = array(
  "memory" => array(
    "caching" => true
  )
);

function setConfig($path, $value, $delimiter = '.') {

    // Just so our example works.
    global $config;

    $tokens = explode($delimiter, $path);

    $currentPiece = &$config;

    foreach($tokens as $token) {
       $currentPiece = &$currentPiece[$token];
    }


    $currentPiece = $value;  

}

setConfig('memory.caching', FALSE);

var_dump($config);


Output:
1
2
3
4
5
6
7
array(1) {
  ["memory"]=>
  array(1) {
    ["caching"]=>
    bool(false)
  }
}


Create a new paste based on this one


Comments: