How to get length of an array in PHP ?

by cristobal , in category: Technology , 4 years ago

How to get length of an array in PHP ?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by bailey_conroy , 4 years ago

PHP count function is used to get the length or numbers of elements in an array

1
2
3
4
5
6
<?php
// initializing an array in PHP
$array=['a','b','c'];
// Outputs 3 
echo count($array);
?>

Related Threads:

How to remove duplicate values from a PHP Array?
How to get no of arguments passed to a PHP Function?
How to get the IP address of the client/user in PHP?
How can you get web browser’s details using PHP?
How to get number of days between two given dates using PHP ?
How to Write a for Loop in Bash in 2025?