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

  1. <?php $user = "John";
  2. $shop = array( array("title"=>"rose", "price"=>1.25 , "number"=>15),
  3.                array("title"=>"daisy", "price"=>0.75 , "number"=>25),
  4.                array("title"=>"orchid", "price"=>1.15 , "number"=>7) 
  5.              ); 
  6. ?>
  7. <html>
  8. <head></head>
  9. <body>
  10. Hello <?php echo $user; ?>!
  11.  
  12. <?php if (count($shop) > 0): ?>
  13. <table>
  14.   <thead>
  15.     <tr>
  16.       <th><?php echo implode('</th><th>', array_keys(current($shop))); ?></th>
  17.     </tr>
  18.   </thead>
  19.   <tbody>
  20. <?php foreach ($shop as $row): array_map('htmlentities', $row); ?>
  21.     <tr>
  22.       <td><?php echo implode('</td><td>', $row); ?></td>
  23.     </tr>
  24. <?php endforeach; ?>
  25.   </tbody>
  26. </table>
  27. <?php endif; ?>
  28. </body>
  29. </html>
File Description
  • php2
  • PHP Code
  • 11 Apr-2021
  • 692 Bytes
You can Share it: