Arrays -accessing - 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 -accessing .php

  1.  
  2.  
  3. <?php
  4. $nutrition = [
  5. 'fat'     => 16,
  6. 'sugar'   => 51,
  7. 'salt'    => 6.3,
  8.  
  9. ];
  10.  
  11. ?>
  12.  
  13. <!doctype html>
  14. <html>
  15. <head>
  16. <meta charset="utf-8">
  17. <title>Create & Access Associiative ARRAY</title>
  18. </head>
  19.  
  20. <body>
  21.        
  22.         <h1>The Candy Store</h1>
  23.         <h2>Nutrition (per100g)</2>
  24.         <p> Fat: <?php echo $nutrition ['fat']; ?>%</p>
  25.         <p> Sugar: <?php echo $nutrition ['sugar']; ?>%</p>
  26.         <p> fat: <?php echo $nutrition ['salt']; ?>%</p>
  27.        
  28. </body>
  29. </html>
File Description
  • Arrays -accessing
  • PHP Code
  • 23 May-2022
  • 432 Bytes
You can Share it: