LoopsStuff - 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 LoopsStuff.php

  1. <?php
  2.  
  3. //Rules are relaxed in php
  4. //Simple to declare an array - not restircted to a single data type
  5.  
  6. $mybook = array('John', 'Ringo', 'George', 'Paul');
  7.  
  8. print_r($mybook); //simple solution for displaying an array
  9.  
  10. //echo used most of the time to print.
  11.  
  12. //We can loop through our array....
  13.  
  14. foreach($mybook as $val)  { // as means next element is treated as an element
  15.  
  16.     echo "<p>$val</p>";
  17.  
  18. }
File Description
  • LoopsStuff
  • PHP Code
  • 25 Feb-2021
  • 399 Bytes
You can Share it: