protected static function removeByIndex($array, $indices)
    {
        // Create a reference to the original array.
        $a = &$array;
        // Count all passed indices, remove one because arrays are zero based.
        $c = count($indices) - 1;
        // Iterate over all passed indices.
        for ($i = 0; $i <= $c; ++$i) {
            // Make sure the index to go down for deletion actually exists.
            if (!array_key_exists($indices[$i], $a)) {
                throw new ArrayStorageException(
                    sprintf('"%s" does not exist in storage object', $indices[$i])
                );
            }
            // This is the target if we reached the last index that was passed.
            if ($i === $c) {
                unset($a[$indices[$i]]);
            } elseif (is_array($a[$indices[$i]])) {
                // Make sure we have an array to go further down.
                $a = &$a[$indices[$i]];
            } else {
                throw new ArrayStorageException(
                    sprintf('"%s" does not exist in storage object', $indices[$i])
                );
            }
        }
        return $array;
    }
protected static function removeByIndex($array, $indices)
    {
        // Create a reference to the original array.
        $a = &$array;
        // Count all passed indices, remove one because arrays are zero based.
        $c = count($indices) - 1;
        // Iterate over all passed indices.
        for ($i = 0; $i <= $c; ++$i) {
            // Make sure the index to go down for deletion actually exists.
            if (!array_key_exists($indices[$i], $a)) {
                throw new ArrayStorageException(
                    sprintf('"%s" does not exist in storage object', $indices[$i])
                );
            }
            // This is the target if we reached the last index that was passed.
            if ($i === $c) {
                unset($a[$indices[$i]]);
            } elseif (is_array($a[$indices[$i]])) {
                // Make sure we have an array to go further down.
                $a = &$a[$indices[$i]];
            } else {
                throw new ArrayStorageException(
                    sprintf('"%s" does not exist in storage object', $indices[$i])
                );
            }
        }
        return $array;
    }
protected static function removeByIndex ( $ array , $ indices ) { // Create a reference to the original array. $ a = & $ array ; // Count all passed indices, remove one because arrays are zero based. $ c = count ( $ indices ) - 1 ; // Iterate over all passed indices. for ( $ i = 0 ; $ i <= $ c ; ++ $ i ) { // Make sure the index to go down for deletion actually exists. if ( ! array_key_exists ( $ indices [ $ i ] , $ a ) ) { throw new ArrayStorageException ( sprintf ( '"%s" does not exist in storage object' , $ indices [ $ i ] ) ) ; } // This is the target if we reached the last index that was passed. if ( $ i === $ c ) { unset ( $ a [ $ indices [ $ i ] ] ) ; } elseif ( is_array ( $ a [ $ indices [ $ i ] ] ) ) { // Make sure we have an array to go further down. $ a = & $ a [ $ indices [ $ i ] ] ; } else { throw new ArrayStorageException ( sprintf ( '"%s" does not exist in storage object' , $ indices [ $ i ] ) ) ; } } return $ array ; }
Remove index from multi-dimensional array.

https://stackoverflow.com/questions/26661828/

@param array $array
The array to remove the index from.
@param array $indices
Indexed array containing the indices chain up to the index that should be
removed.
@return array
The array with the index removed.
@throws \WebServCo\Framework\Exceptions\ArrayStorageException
If the index does not exist within the array.
Remove index from multi - dimensional array .