note 94301 deleted from function.unset by thiago

From: Date: Wed, 28 Oct 2009 12:25:38 +0000
Subject: note 94301 deleted from function.unset by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-162172@lists.php.net to get a copy of this message
Note Submitter: fsockopen_AT_yahoo_DOT_it ---- if have a configuration array like this: $options = array( 'foo' => array( 'bar' => array( 'baz' = 'something' ) ) 'fruit' => 'apple' }; I was searching a way to remove a part (the 'baz' element) of the array starting from a syntax like: remove foo.bar.baz or foo/bar/baz <?php $optionToRemove = 'foo.bar.baz'; $separator = '.'; // or "/" $parts = explode($separator, $optionToRemove); $GLOBALS['tmpvar'] = $options; $evalString = 'unset($GLOBALS['tmpvar']["' . implode('"]["', $parts) . '"]);'; eval($evalString); $options = $GLOBALS['tmpvar']; unset($GLOBALS['tmpvar']); ?>

« previous php.notes (#162172) next »