The Count function
By S.Tanveer
Published: 14 Aug 2006
PHP Count function
The Count function in PHP
The Count Function count the total number of element in Array or in object. You can use count function in FOR LOOP when you want access the element of array. For example if we have array:
For example:
$student = array( "Majeed" , "Saleem" , "Noman" , "Qasim");
$total_element=Count($student);
echo $total_elemen;
Although foreach loop easily access the element of array. but you can also use for loop for accessing the element of one dimensional or two dimensional array.
$student = array( "Majeed" , "Saleem" , "Noman" , "Qasim"); $total_element=Count($student); for(i=0 ; i< $total_element ; i++) { echo $student[i] . "
" ; }