English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Online Tools

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

Object Function

PHP Array Function Manual

PHP sizeof() Function Usage and Example

count() is an alias of the sizeof() function

Syntax

sizeof($array, $mode);

Definition and Usage

Calculates the number of elements in an array or properties in an object.1If the optional mode parameter is set to COUNT_RECURSIVE (or

Parameter

Serial NumberParameters and Description
1

array

Required. Specify an array

2

mode

Optional. Specify the mode of the function.

Return Value

Returns the number of elements in an array.

Online Example

<?php
   $a[0] = 1;
   $a[1] = 3;
   $a[2] = 5;
   $result = sizeof($a);
   
   print($result);
?>
Test and see‹/›

Output Result:

3

PHP Array Function Manual