April 2026
Intermediate
1009 pages
34h 15m
English
Let's assume that you don't know very much about the return of a function, but you suspect that it is usually an array and need some information from it. PHP offers some interesting functions for this.
You already know about count(Array). This function counts the number of elements in an array. If you specify COUNT_RECURSIVE or 1 as the second parameter, then all elements are counted recursively. This means that count(Array, Mode) also counts the elements in nested arrays. Assume the following array:
$ibw_stockprices = array("1.1.2015" => 232, "1.1.2020" => 254); $stockprices = array("IBW" => $ibw_stockprices);
If you now count all elements without the mode, like this:
print count($stockprices);
then you get 1. If, on the other ...
Read now
Unlock full access