Skip to content

Instantly share code, notes, and snippets.

@alxpsr
Created May 28, 2016 10:10
Show Gist options
  • Save alxpsr/abe87d48b8df5f2913d1aa8e072beb36 to your computer and use it in GitHub Desktop.
Save alxpsr/abe87d48b8df5f2913d1aa8e072beb36 to your computer and use it in GitHub Desktop.
Подсчет элементов ассоциативного массива второго уровня вложенности
$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