Dear Robert,
On 14.12.2011, at 22:02, Robert Cummings wrote:
> $path = ‘/path/to/data/in/my/arbitrarily/deep/array/';
> $array = $someBigFatArray;
> $focus = &$array;
> foreach( explode( '/', $path ) as $step )
> {
> if ($step === '' || $step === 'CONFIGURATION’)
> {
> continue;
> }
> if( isset( $focus[$step] ) )
> {
> $focus = &$focus[$step];
> }
> else
> {
> unset( $focus );
> $focus = null;
> break;
> }
> }
> echo "<pre>"; echo var_export($focus, TRUE); echo "</pre>";
This solution is excellent! I modified it a little to match for empty $step and
then continue, just in case there is a leading, ending or doubled “/“ and same
for CONFIGURATION which will be my indicator to find the values where we expect
a value replacement.
if ($step === '' || $step === 'CONFIGURATION’) {
continue;
}
Great thing!
Thanks a lot to all!
Cheers, Nils
--
http://webint.cryptonode.de / a Fractal project
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php