1// using count() we can get proper length of the array
2$names = array("Ankur","Raj","Ram","Suresh");
3// pass array into count() as parameter it will return array length
4echo count($names);
5
6// output : 4
1var arr = [10,20,30,40,50]; //An Array is defined with 5 instances
2
3var len= arr.length; //Now arr.length returns 5.Basically, len=5.
4console.log(len); //gives 5
5console.log(arr.length); //also gives 5
1<?php
2 $names = array("Ankur","Raj","Ram","Suresh");
3 echo count($names);
4 $cars=array("Volvo","BMW","Toyota");
5 echo count($cars);
6// test