References are not like hard-links. If you unset a reference, this will not unset the origin value.
<?php
$a = 5;
xdebug_debug_zval('a'); // a: (refcount=1, is_ref=0), int 5
$b = &$a;
xdebug_debug_zval('a'); // a: (refcount=2, is_ref=1), int 5
xdebug_debug_zval('b'); // b: (refcount=2, is_ref=1), int 5
unset($b);
xdebug_debug_zval('a'); // a: (refcount=1, is_ref=0), int 5
Why not write a little Config
class which abstracts the data (array)? Since objects are always passed by reference you won't need to handle this at your own.
class Config
{
// ...
}
$config = new Config(array(
'db' => array(
'name' => 'mydatabase',
'user' => 'root',
'pass' => '12345',
)
));
$config->get('db.user');
$config->set('db.user', 'newuser');
$config->unset('db.user');
//...