# sizeof() function in PHP

PHPProgrammingServer Side Programming

The sizeof() function in PHP is an alias of count() function. The sizeof() function counts elements in an array, or properties in an object. It returns the number of elements in an array.

## Syntax

sizeof(arr, mode)

## Parameters

• arr − The specified array.

• mode − Specifies the mode. Possible values are 0 or 1. 0: Do not count all the elements, 1: Count all the elements.

## Return

The sizeof() function returns the number of elements in an array.

## Example

The following is an example −

Live Demo

<?php
$students = array("Jack","Peter", "Anne","David"); echo sizeof($students);
?>

## Output

The following is the output −

4
Updated on 23-Dec-2019 08:47:44