Example 1 — Count the Elements of an Array
sizeof() simply returns how many elements an array holds.
<?php
$items = [1, 2, 3];
$empty = [];
echo sizeof($items), PHP_EOL;
echo sizeof($empty), PHP_EOL; How It Works
- $items has three elements.
- sizeof($items) returns 3.
- $empty has no elements.
- sizeof($empty) returns 0.

