Created
May 28, 2016 10:10
-
-
Save alxpsr/abe87d48b8df5f2913d1aa8e072beb36 to your computer and use it in GitHub Desktop.
Подсчет элементов ассоциативного массива второго уровня вложенности
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$test_array = array( | |
"person-1" => array( | |
"name" => "pete", | |
"lastname" => "rock", | |
"age" => "20" | |
), | |
"person-2" => array( | |
"name" => "jay", | |
"lastname" => "dee", | |
"age" => "40" | |
) | |
); | |
если у каждого, то | |
foreach ($test_array as $key => $value) { | |
echo $key . ' = ' . count($value); | |
} | |
если у первого, то | |
echo count($test_array[key($test_array)]); | |
или | |
echo count(current($test_array)); | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment