Как получить значение массива php
Перейти к содержимому

Как получить значение массива php

  • автор:

array_values

array_values() возвращает массив со всеми элементами массива array . Она также заново индексирует возвращаемый массив числовыми индексами.

Список параметров

Возвращаемые значения

Возвращает индексированный массив значений.

Примеры

Пример #1 Пример использования array_values()

$array = array( «size» => «XL» , «color» => «gold» );
print_r ( array_values ( $array ));
?>

Результат выполнения данного примера:

Array ( [0] => XL [1] => gold )

Смотрите также

  • array_keys() — Возвращает все или некоторое подмножество ключей массива
  • array_combine() — Создаёт новый массив, используя один массив в качестве ключей, а другой для его значений

User Contributed Notes 6 notes

9 years ago

Remember, array_values() will ignore your beautiful numeric indexes, it will renumber them according tho the ‘foreach’ ordering:

print_r ( array_values ( $a ));
==>
Array(
[ 0 ] => 11
[ 1 ] => 22
[ 2 ] => 33
[ 3 ] => 44
)
?>

20 years ago

Just a warning that re-indexing an array by array_values() may cause you to reach the memory limit unexpectly.

For example, if your PHP momory_limits is 8MB,
and says there’s a BIG array $bigArray which allocate 5MB of memory.

Doing this will cause PHP exceeds the momory limits:

$bigArray = array_values ( $bigArray );
?>

It’s because array_values() does not re-index $bigArray directly,
it just re-index it into another array, and assign to itself later.

12 years ago

This is another way to get value from a multidimensional array, but for versions of php >= 5.3.x
/**
* Get all values from specific key in a multidimensional array
*
* @param $key string
* @param $arr array
* @return null|string|array
*/
function array_value_recursive ( $key , array $arr ) $val = array();
array_walk_recursive ( $arr , function( $v , $k ) use( $key , & $val ) if( $k == $key ) array_push ( $val , $v );
>);
return count ( $val ) > 1 ? $val : array_pop ( $val );
>

$arr = array(
‘foo’ => ‘foo’ ,
‘bar’ => array(
‘baz’ => ‘baz’ ,
‘candy’ => ‘candy’ ,
‘vegetable’ => array(
‘carrot’ => ‘carrot’ ,
)
),
‘vegetable’ => array(
‘carrot’ => ‘carrot2’ ,
),
‘fruits’ => ‘fruits’ ,
);

var_dump ( array_value_recursive ( ‘carrot’ , $arr )); // array(2) < [0]=>string(6) «carrot» [1]=> string(7) «carrot2» >
var_dump ( array_value_recursive ( ‘apple’ , $arr )); // null
var_dump ( array_value_recursive ( ‘baz’ , $arr )); // string(3) «baz»
var_dump ( array_value_recursive ( ‘candy’ , $arr )); // string(5) «candy»
var_dump ( array_value_recursive ( ‘pear’ , $arr )); // null
?>

16 years ago

Most of the array_flatten functions don’t allow preservation of keys. Mine allows preserve, don’t preserve, and preserve only strings (default).

// recursively reduces deep arrays to single-dimensional arrays
// $preserve_keys: (0=>never, 1=>strings, 2=>always)
function array_flatten($array, $preserve_keys = 1, &$newArray = Array()) foreach ($array as $key => $child) if (is_array($child)) $newArray =& array_flatten($child, $preserve_keys, $newArray);
> elseif ($preserve_keys + is_string($key) > 1) $newArray[$key] = $child;
> else $newArray[] = $child;
>
>
return $newArray;
>

echo ‘var_dump($array);’.»\n»;
var_dump($array);
echo ‘var_dump(array_flatten($array, 0));’.»\n»;
var_dump(array_flatten($array, 0));
echo ‘var_dump(array_flatten($array, 1));’.»\n»;
var_dump(array_flatten($array, 1));
echo ‘var_dump(array_flatten($array, 2));’.»\n»;
var_dump(array_flatten($array, 2));
?>

15 years ago

If you are looking for a way to count the total number of times a specific value appears in array, use this function:

function array_value_count ( $match , $array )
<
$count = 0 ;

foreach ( $array as $key => $value )
<
if ( $value == $match )
<
$count ++;
>
>

return $count ;
>
?>

This should really be a native function of PHP.

19 years ago

/**
flatten an arbitrarily deep multidimensional array
into a list of its scalar values
(may be inefficient for large structures)
(will infinite recurse on self-referential structures)
(could be extended to handle objects)
*/
function array_values_recursive ( $ary )
$lst = array();
foreach( array_keys ( $ary ) as $k ) $v = $ary [ $k ];
if ( is_scalar ( $v )) $lst [] = $v ;
> elseif ( is_array ( $v )) $lst = array_merge ( $lst ,
array_values_recursive ( $v )
);
>
>
return $lst ;
>
?>

code till dawn! -mark meves!

  • Функции для работы с массивами
    • array_​change_​key_​case
    • array_​chunk
    • array_​column
    • array_​combine
    • array_​count_​values
    • array_​diff_​assoc
    • array_​diff_​key
    • array_​diff_​uassoc
    • array_​diff_​ukey
    • array_​diff
    • array_​fill_​keys
    • array_​fill
    • array_​filter
    • array_​flip
    • array_​intersect_​assoc
    • array_​intersect_​key
    • array_​intersect_​uassoc
    • array_​intersect_​ukey
    • array_​intersect
    • array_​is_​list
    • array_​key_​exists
    • array_​key_​first
    • array_​key_​last
    • array_​keys
    • array_​map
    • array_​merge_​recursive
    • array_​merge
    • array_​multisort
    • array_​pad
    • array_​pop
    • array_​product
    • array_​push
    • array_​rand
    • array_​reduce
    • array_​replace_​recursive
    • array_​replace
    • array_​reverse
    • array_​search
    • array_​shift
    • array_​slice
    • array_​splice
    • array_​sum
    • array_​udiff_​assoc
    • array_​udiff_​uassoc
    • array_​udiff
    • array_​uintersect_​assoc
    • array_​uintersect_​uassoc
    • array_​uintersect
    • array_​unique
    • array_​unshift
    • array_​values
    • array_​walk_​recursive
    • array_​walk
    • array
    • arsort
    • asort
    • compact
    • count
    • current
    • end
    • extract
    • in_​array
    • key_​exists
    • key
    • krsort
    • ksort
    • list
    • natcasesort
    • natsort
    • next
    • pos
    • prev
    • range
    • reset
    • rsort
    • shuffle
    • sizeof
    • sort
    • uasort
    • uksort
    • usort
    • each
    • Copyright © 2001-2023 The PHP Group
    • My PHP.net
    • Contact
    • Other PHP.net sites
    • Privacy policy

    Вывести значение из массива php

    сильно не пинайте, знания PHP стартовые:) Не получается вывести значение из массива (необходимо вывести дату [formatted] и время [time] и [timeto].

    print_r( $jckwds->get_reserved_slot() ); 

    выводит следующее:

    Array ( [id] => 20170624_0 [date] => Array ( [formatted] => 24/06/2017 [id] => 20170624 ) [time] => Array ( [timefrom] => Array ( [time] => 02:30 [stripped] => 0230 ) [timeto] => Array ( [time] => 10:45 [stripped] => 1045 ) [cutoff] => [lockout] => 4 [shipping_methods] => Array ( [0] => any ) [fee] => Array ( [value] => [formatted] => €0,00 ) [days] => Array ( [0] => 0 [1] => 1 [2] => 6 ) [id] => 0 [time_id] => 02301045 [formatted] => 02:30 AM - 10:45 AM [formatted_with_fee] => 02:30 AM - 10:45 AM [value] => 0|0.00 ) ) 

    Код, которым пытаюсь вывести хотя бы дату:

    global $jckwds; $jckw = $jckwds->get_reserved_slot(); foreach($jckw as $key)

    Отслеживать
    9,665 9 9 золотых знаков 24 24 серебряных знака 35 35 бронзовых знаков
    задан 17 июн 2017 в 8:32
    1 1 1 серебряный знак 1 1 бронзовый знак
    19 июн 2017 в 2:16

    2 ответа 2

    Сортировка: Сброс на вариант по умолчанию

    Для того чтобы легко понять структуру многомерного массива, в первую очередь посмотрите на строение.

    Array ( [id] => 20170624_0 [date] => Array ( [formatted] => 24/06/2017 [id] => 20170624 ) [time] => Array ( [timefrom] => Array ( [time] => 02:30 [stripped] => 0230 ) [timeto] => Array ( [time] => 10:45 [stripped] => 1045 ) [cutoff] => [lockout] => 4 [shipping_methods] => Array ( [0] => any ) [fee] => Array ( [value] => [formatted] => €0,00 ) [days] => Array ( [0] => 0 [1] => 1 [2] => 6 ) [id] => 0 [time_id] => 02301045 [formatted] => 02:30 AM - 10:45 AM [formatted_with_fee] => 02:30 AM - 10:45 AM [value] => 0|0.00 ) ) 

    Дальше через foreach можете получить пару ключ=>значение

    foreach($jckw as $key=>$val) < echo $val; /* или */ echo $jckw[$key]; >

    В переменной $val уже находятся значения, их можно получать и без ключа, если вам нужно получить одно значение по ключу, например

    echo $jckw[‘date’][‘formatted’]; или echo $jckw[‘time’][‘timefrom’][‘time’];

    Смотрите также

    A simple trick that can help you to guess what diff/intersect or sort function does by name.

    [suffix] assoc — additional index check. Compares both value and index.

    Example: array_diff_assoc, array_intersect_assoc.

    [suffix] key — index only check. Ignores value of array, compares only indexes.

    Example: array_diff_key, array_intersect_key.

    [suffix] **empty** — no «key» or «assoc» word in suffix. Compares values only. Ignores indexes of array.

    Example: array_diff, array_intersect.

    [prefix] u — will do comparison with user defined function. Letter u can be used twice in some functions (like array_udiff_uassoc), this means that you have to use 2 functions (one for value, one for index).

    Example: array_udiff_uassoc, array_uintersect_assoc.

    This also works with array sort functions:

    [prefix] a — associative. Will preserve keys.

    Example: arsort, asort.

    [prefix] k — key sort. Will sort array by keys.

    Example: uksort, ksort.

    [prefix] r — reverse. Will sort array in reverse order.

    Example: rsort, krsort.

    [prefix] u — sort by user defined function (same as for diff/intersect).

    Example: usort, uasort.

    15 years ago

    Big arrays use a lot of memory possibly resulting in memory limit errors. You can reduce memory usage on your script by destroying them as soon as you´re done with them. I was able to get over a few megabytes of memory by simply destroying some variables I didn´t use anymore.
    You can view the memory usage/gain by using the funcion memory_get_usage(). Hope this helps!

    4 years ago

    I need to take an element from the Array and change its position within the Array by moving the rest of the elements as required.
    This is the function that does it. The first parameter is the working Array. The second is the position of the element to move and the third is the position where to move the element.
    The function returns the modified Array.
    function array_move_elem ( $array , $from , $to ) if ( $from == $to ) < return $array ; >
    $c = count ( $array );
    if (( $c > $from ) and ( $c > $to )) if ( $from < $to ) $f = $array [ $from ];
    for ( $i = $from ; $i < $to ; $i ++) $array [ $i ] = $array [ $i + 1 ];
    >
    $array [ $to ] = $f ;
    > else $f = $array [ $from ];
    for ( $i = $from ; $i > $to ; $i —) $array [ $i ] = $array [ $i — 1 ];
    >
    $array [ $to ] = $f ;
    >

    ?>
    Examples:
    $array = array( ‘Cero’ , ‘Uno’ , ‘Dos’ , ‘Tres’ , ‘Cuatro’ , ‘Cinco’ , ‘Seis’ , ‘Siete’ , ‘Ocho’ , ‘Nueve’ , ‘Diez’ );
    $array = array_move_elem ( $array , 3 , 5 ); // Move element in position 3 to position 5.
    print_r ( $array );

    $array = array_move_elem ( $array , 5 , 3 ); // Move element in position 5 to position 3, leaving array as it was. 😉
    print_r ( $array );

    ?>
    Return:
    Array ( [ 0 ] => Cero [ 1 ] => Uno [ 2 ] => Dos [ 3 ] => Cuatro [ 4 ] => Cinco [ 5 ] => Tres [ 6 ] => Seis [ 7 ] => Siete [ 8 ] => Ocho [ 9 ] => Nueve [ 10 ] => Diez )
    Array ( [ 0 ] => Cero [ 1 ] => Uno [ 2 ] => Dos [ 3 ] => Tres [ 4 ] => Cuatro [ 5 ] => Cinco [ 6 ] => Seis [ 7 ] => Siete [ 8 ] => Ocho [ 9 ] => Nueve [ 10 ] => Diez )
    ?>

    17 years ago

    Here is a function to find out the maximum depth of a multidimensional array.

    // return depth of given array
    // if Array is a string ArrayDepth() will return 0
    // usage: int ArrayDepth(array Array)

    function ArrayDepth ( $Array , $DepthCount =- 1 , $DepthArray =array()) $DepthCount ++;
    if ( is_array ( $Array ))
    foreach ( $Array as $Key => $Value )
    $DepthArray []= ArrayDepth ( $Value , $DepthCount );
    else
    return $DepthCount ;
    foreach( $DepthArray as $Value )
    $Depth = $Value > $Depth ? $Value : $Depth ;
    return $Depth ;
    >
    ?>

    3 years ago

    Updated code of ‘indioeuropeo’ with option to input string-based keys.

    FUNCTION:
    function array_move_elem ( $array , $from , $to ) // return if non-numeric couldn’t be found or from=to
    if(! is_numeric ( $from )) if( array_search ( $from , array_keys ( $array ))!== FALSE ) $from = array_search ( $from , array_keys ( $array ));
    >else return $array ;
    >
    >
    $array_numeric_keys = array();
    foreach( $array as $k => $v ) $array_numeric_keys [] = $k ;
    >
    if ( $from == $to ) < return $array ; >
    $c = count ( $array_numeric_keys );
    if (( $c > $from ) and ( $c > $to )) if ( $from < $to ) $f = $array_numeric_keys [ $from ];
    for ( $i = $from ; $i < $to ; $i ++) $array_numeric_keys [ $i ] = $array_numeric_keys [ $i + 1 ];
    >
    $array_numeric_keys [ $to ] = $f ;
    > else $f = $array_numeric_keys [ $from ];
    for ( $i = $from ; $i > $to ; $i —) $array_numeric_keys [ $i ] = $array_numeric_keys [ $i — 1 ];
    >
    $array_numeric_keys [ $to ] = $f ;
    >

    >
    $array_new = array();
    foreach( $array_numeric_keys as $v ) $array_new [ $v ] = $array [ $v ];
    >
    return $array_new ;
    >
    ?>

    11 years ago

    Short function for making a recursive array copy while cloning objects on the way.

    function arrayCopy ( array $array ) $result = array();
    foreach( $array as $key => $val ) if( is_array ( $val ) ) $result [ $key ] = arrayCopy ( $val );
    > elseif ( is_object ( $val ) ) $result [ $key ] = clone $val ;
    > else $result [ $key ] = $val ;
    >
    >
    return $result ;
    >
    ?>

    12 years ago

    While PHP has well over three-score array functions, array_rotate is strangely missing as of PHP 5.3. Searching online offered several solutions, but the ones I found have defects such as inefficiently looping through the array or ignoring keys.

    The following array_rotate() function uses array_merge and array_shift to reliably rotate an array forwards or backwards, preserving keys. If you know you can trust your $array to be an array and $shift to be between 0 and the length of your array, you can skip the function definition and use just the return expression in your code.

    function array_rotate ( $array , $shift ) if(! is_array ( $array ) || ! is_numeric ( $shift )) if(! is_array ( $array )) error_log ( __FUNCTION__ . ‘ expects first argument to be array; ‘ . gettype ( $array ). ‘ received.’ );
    if(! is_numeric ( $shift )) error_log ( __FUNCTION__ . ‘ expects second argument to be numeric; ‘ . gettype ( $shift ). » ` $shift ` received.» );
    return $array ;
    >
    $shift %= count ( $array ); //we won’t try to shift more than one array length
    if( $shift < 0 ) $shift += count ( $array ); //handle negative shifts as positive
    return array_merge ( array_slice ( $array , $shift , NULL , true ), array_slice ( $array , 0 , $shift , true ));
    >
    ?>
    A few simple tests:
    $array =array( «foo» => 1 , «bar» => 2 , «baz» => 3 , 4 , 5 );

    print_r ( array_rotate ( $array , 2 ));
    print_r ( array_rotate ( $array , — 2 ));
    print_r ( array_rotate ( $array , count ( $array )));
    print_r ( array_rotate ( $array , «4» ));
    print_r ( array_rotate ( $array , — 9 ));
    ?>

    8 years ago

    /*to change an index without rewriting the whole table and leave at the same place.
    */
    function change_index (& $tableau , $old_key , $new_key ) $changed = FALSE ;
    $temp = 0 ;
    foreach ( $tableau as $key => $value ) switch ( $changed ) case FALSE :
    //creates the new key and deletes the old
    if ( $key == $old_key ) $tableau [ $new_key ] = $tableau [ $old_key ];
    unset( $tableau [ $old_key ]);
    $changed = TRUE ;
    >
    break;

    case TRUE :
    //moves following keys
    if ( $key != $new_key ) $temp = $tableau [ $key ];
    unset( $tableau [ $key ]);
    $tableau [ $key ] = $temp ;
    break;
    >
    else < $changed = FALSE ;>//stop
    >
    >
    array_values ( $tableau ); //free_memory
    >

    //Result :
    $tableau = array( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 );
    $res = print_r ( $tableau , TRUE );
    $longueur = strlen ( $res ) — 1 ;
    echo «Old array :\n» . substr ( $res , 8 , $longueur ) . «\n» ;

    change_index ( $tableau , 2 , ‘number 2’ );
    $res = print_r ( $tableau , TRUE );
    $longueur = strlen ( $res ) — 10 ;
    echo «New array :\n» . substr ( $res , 8 , $longueur ) . «\n» ;

    array_search

    Замечание:

    Если needle является строкой, сравнение происходит с учётом регистра.

    Если третий параметр strict установлен в true , то функция array_search() будет искать идентичные элементы в haystack . Это означает, что также будут проверяться типы needle в haystack , а объекты должны быть одним и тем же экземпляром.

    Возвращаемые значения

    Возвращает ключ для needle , если он был найден в массиве, иначе false .

    Если needle присутствует в haystack более одного раза, будет возвращён первый найденный ключ. Для того, чтобы возвратить ключи для всех найденных значений, используйте функцию array_keys() с необязательным параметром search_value .

    Внимание

    Эта функция может возвращать как логическое значение false , так и значение не типа boolean, которое приводится к false . За более подробной информацией обратитесь к разделу Булев тип. Используйте оператор === для проверки значения, возвращаемого этой функцией.

    Примеры

    Пример #1 Пример использования array_search()

    $array = array( 0 => ‘blue’ , 1 => ‘red’ , 2 => ‘green’ , 3 => ‘red’ );

    $key = array_search ( ‘green’ , $array ); // $key = 2;
    $key = array_search ( ‘red’ , $array ); // $key = 1;
    ?>

    Смотрите также

    • array_keys() — Возвращает все или некоторое подмножество ключей массива
    • array_values() — Выбирает все значения массива
    • array_key_exists() — Проверяет, присутствует ли в массиве указанный ключ или индекс
    • in_array() — Проверяет, присутствует ли в массиве значение

    User Contributed Notes 16 notes

    6 years ago

    About searcing in multi-dimentional arrays; two notes on «xfoxawy at gmail dot com»;

    It perfectly searches through multi-dimentional arrays combined with array_column() (min php 5.5.0) but it may not return the values you’d expect.

    Since array_column() will produce a resulting array; it won’t preserve your multi-dimentional array’s keys. So if you check against your keys, it will fail.

    $people = array(
    2 => array(
    ‘name’ => ‘John’ ,
    ‘fav_color’ => ‘green’
    ),
    5 => array(
    ‘name’ => ‘Samuel’ ,
    ‘fav_color’ => ‘blue’
    )
    );

    $found_key = array_search ( ‘blue’ , array_column ( $people , ‘fav_color’ ));
    ?>

    Here, you could expect that the $found_key would be «5» but it’s NOT. It will be 1. Since it’s the second element of the produced array by the array_column() function.

    Secondly, if your array is big, I would recommend you to first assign a new variable so that it wouldn’t call array_column() for each element it searches. For a better performance, you could do;

    $colors = array_column ( $people , ‘fav_color’ );
    $found_key = array_search ( ‘blue’ , $colors );
    ?>

    20 years ago

    If you are using the result of array_search in a condition statement, make sure you use the === operator instead of == to test whether or not it found a match. Otherwise, searching through an array with numeric indicies will result in index 0 always getting evaluated as false/null. This nuance cost me a lot of time and sanity, so I hope this helps someone. In case you don’t know what I’m talking about, here’s an example:

    $code = array( «a» , «b» , «a» , «c» , «a» , «b» , «b» ); // infamous abacabb mortal kombat code 😛

    // this is WRONG
    while (( $key = array_search ( «a» , $code )) != NULL )
    <
    // infinite loop, regardless of the unset
    unset( $code [ $key ]);
    >

    // this is _RIGHT_
    while (( $key = array_search ( «a» , $code )) !== NULL )
    <
    // loop will terminate
    unset( $code [ $key ]);
    >
    ?>

    12 years ago

    for searching case insensitive better this:

    array_search ( strtolower ( $element ), array_map ( ‘strtolower’ , $array ));
    ?>

    2 years ago

    var_dump ( array_search ( ‘needle’ , [ 0 => 0 ])); // int(0) (!)

    var_dump ( array_search ( ‘needle’ , [ 0 => 0 ], true )); // bool(false)

    var_dump ( array_search ( ‘needle’ , [ 0 => 0 ])); // bool(false)

    17 years ago

    To expand on previous comments, here are some examples of
    where using array_search within an IF statement can go
    wrong when you want to use the array key thats returned.

    Take the following two arrays you wish to search:

    $fruit_array = array( «apple» , «pear» , «orange» );
    $fruit_array = array( «a» => «apple» , «b» => «pear» , «c» => «orange» );

    if ( $i = array_search ( «apple» , $fruit_array ))
    //PROBLEM: the first array returns a key of 0 and IF treats it as FALSE

    if ( is_numeric ( $i = array_search ( «apple» , $fruit_array )))
    //PROBLEM: works on numeric keys of the first array but fails on the second

    if ( $i = is_numeric ( array_search ( «apple» , $fruit_array )))
    //PROBLEM: using the above in the wrong order causes $i to always equal 1

    if ( $i = array_search ( «apple» , $fruit_array ) !== FALSE )
    //PROBLEM: explicit with no extra brackets causes $i to always equal 1

    if (( $i = array_search ( «apple» , $fruit_array )) !== FALSE )
    //YES: works on both arrays returning their keys
    ?>

    5 years ago

    Despite PHP’s amazing assortment of array functions and juggling maneuvers, I found myself needing a way to get the FULL array key mapping to a specific value. This function does that, and returns an array of the appropriate keys to get to said (first) value occurrence.

    function array_recursive_search_key_map($needle, $haystack) foreach($haystack as $first_level_key=>$value) if ($needle === $value) return array($first_level_key);
    > elseif (is_array($value)) $callback = array_recursive_search_key_map($needle, $value);
    if ($callback) return array_merge(array($first_level_key), $callback);
    >
    >
    >
    return false;
    >

    $nested_array = $sample_array = array(
    ‘a’ => array(
    ‘one’ => array (‘aaa’ => ‘apple’, ‘bbb’ => ‘berry’, ‘ccc’ => ‘cantalope’),
    ‘two’ => array (‘ddd’ => ‘dog’, ‘eee’ => ‘elephant’, ‘fff’ => ‘fox’)
    ),
    ‘b’ => array(
    ‘three’ => array (‘ggg’ => ‘glad’, ‘hhh’ => ‘happy’, ‘iii’ => ‘insane’),
    ‘four’ => array (‘jjj’ => ‘jim’, ‘kkk’ => ‘kim’, ‘lll’ => ‘liam’)
    ),
    ‘c’ => array(
    ‘five’ => array (‘mmm’ => ‘mow’, ‘nnn’ => ‘no’, ‘ooo’ => ‘ohh’),
    ‘six’ => array (‘ppp’ => ‘pidgeon’, ‘qqq’ => ‘quail’, ‘rrr’ => ‘rooster’)
    )
    );

    $array_keymap = array_recursive_search_key_map($search_value, $nested_array);

    But again, with the above solution, PHP again falls short on how to dynamically access a specific element’s value within the nested array. For that, I wrote a 2nd function to pull the value that was mapped above.

    function array_get_nested_value($keymap, $array)
    $nest_depth = sizeof($keymap);
    $value = $array;
    for ($i = 0; $i < $nest_depth; $i++) $value = $value[$keymap[$i]];
    >

    usage example:
    ——————-
    echo array_get_nested_value($array_keymap, $nested_array); // insane

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *