Closed AlessandroCuba closed 2 years ago
Hi, as said in the TL;DR section, you have to iterate over the whole thing and count the items yourself. It is not possible to know the count beforehand as this is a lazy parser.
$count = 0;
foreach (Items::fromFile('file.json') as $item) {
$count++
}
echo $count;
Also, you can use iterator_count()
which will do that for you. Just use iterator_count($items)
. Remember it will still have to iterate the whole thing to get the count and thus will take about the same time.
Hi,
How can I know, how many Items has the JSON?