fork download
  1.  
  2. <html>
  3. <head>
  4. <title>Array manipulation</title>
  5. </head>
  6. <body>
  7. <?php
  8. // create array first
  9. print( "<strong>Creating the first array</strong><br />" );
  10. $first[ 0 ] = "zero";
  11. $first[ 1 ] = "one";
  12. $first[ 2 ] = "two";
  13. $first[] = "three";
  14.  
  15. // print each element’s index and value
  16. for ( $i = 0; $i < count( $first ); $i++ )
  17. print( "Element $i is $first[$i] <br />" );
  18.  
  19. print( "<br /><strong>Creating the second array
  20. </strong><br />" );
  21.  
  22. // call function array to create array second
  23. $second = array( "zero", "one", "two", "three" );
  24.  
  25. for ( $i = 0; $i < count( $second ); $i++ )
  26. print( "Element $i is $second[$i] <br />" );
  27.  
  28. print( "<br /><strong>Creating the third array
  29. </strong><br />" );
  30.  
  31. ?>
  32. </body>
  33. </html>
Success #stdin #stdout 0.02s 25940KB
stdin
Standard input is empty
stdout
 
<html> 
   <head> 
      <title>Array manipulation</title> 
   </head> 
   <body> 
      <strong>Creating the first array</strong><br />Element 0 is zero <br />Element 1 is one <br />Element 2 is two <br />Element 3 is three <br /><br /><strong>Creating the second array 
            </strong><br />Element 0 is zero <br />Element 1 is one <br />Element 2 is two <br />Element 3 is three <br /><br /><strong>Creating the third array 
            </strong><br /> 
   </body> 
</html>