043 - array count and size of using count function = 3
using sizeof function = 3
using sizeof function for mD array = 2
using sizeof function for mD array with mode 1st way= 4
using count function for mD array with mode 2st way= 10
orange
banana
apple
<?php
// 043 - array count & sizeof
echo "</br><span class='myheading'> 043 - array count and size of </span></br>";
$food_043 = array('orange', 'banana', 'apple');
echo 'using count function = ' . count($food_043).'<br>';
echo 'using sizeof function = ' . sizeof($food_043).'<br>';
$food_a_043 = array(
'fruits' => array('orange', 'banana', 'apple','seb'),
'veggie' => array('carrot', 'collard', 'pea','seb')
);
/* (Mode counts all the elements of multidimensional(mD) arrays) */
echo 'using sizeof function for mD array = ' . sizeof($food_a_043).'<br>'; // count only # of array
echo 'using sizeof function for mD array with mode 1st way= ' . sizeof($food_a_043['fruits'],1).'<br>'; // count only fruit values
echo 'using count function for mD array with mode 2st way= ' . count($food_a_043,1).'<br>'; // count all values
$len_043 = count($food_043); // practial use of count/sizeof
for($i_043 = 0; $i_043 < $len_043; $i_043++){
echo $food_043[$i_043] . "<br>";
}
?>