Arrays in PHP - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of Arrays in PHP.php

  1. <?php
  2.  
  3. $mybook = array('John', 'Ringo', 'Geroge', 'Paul');
  4.  
  5. print_r($mybook);
  6.  
  7. //loop round
  8. foreach($mybook as $val) {
  9.     
  10.     echo "<p>$val</p>";
  11.     
  12. }
  13.  
  14. echo "<p>Choose your favourite CMS framework?</p>";
  15.  
  16. echo "<ol>";
  17.  
  18. $frameworks = array("WordPress", "Joolma", "Drupla");
  19.  
  20. foreach($frameworks as $val) {
  21.     
  22.     echo "<li>$val</li>";
  23.  
  24. }
  25.  
  26. echo "</ol>";
File Description
  • Arrays in PHP
  • PHP Code
  • 25 Feb-2021
  • 357 Bytes
You can Share it: