[ create a new paste ] login | about

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

PHP, pasted on Nov 9:
<?php

$indexes = array(1, 3, 0);

$multiDimensionalArray = array(
  '0',
  array('1-0','1-1','1-2',array('2-0','2-1','2-2')),
  array('1-4','1-5','1-6')
);

// $result = magicFunction($indexes, $multiDimensionalArray);

$result = &$multiDimensionalArray;
foreach($indexes as $index)
{
    if (!isset($result[$index]))
        break;
    
    $result = &$result[$index];
}

echo $result;


Output:
1
2-0


Create a new paste based on this one


Comments: