Getting array size : Array Index « Data Structure « PHP

Getting array size

  <title>Getting array size</title>

  $arr = array();

  for( $i = 0; $i < 3; $i++ )
    $arr[ $i ] ="<li>This is element $i</li>";

  foreach( $arr as $value )

  $size = count( $arr );
  echo( "<li>Total number of elements is $size </li>" );


Related examples in the same category

1.Adding elements with []
2.Alternating table row colors
3.Setting an Array's Size
4.Loops through an indexed array of fruit names and creates a new array with the count of each fruit name.