Getting array size : Array Index « Data Structure « PHP






Getting array size

 
<html>
 <head>
  <title>Getting array size</title>
 </head>
 <body> 
  <ul>

  <?php
  $arr = array();

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

  foreach( $arr as $value )
  {
    echo($value);
  }

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

  </ul>
 </body>
</html>
  
  








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.