3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $shop = array( array("rose", 1.25 , 15), array("daisy", 0.75 , 25), array("orchid", 1.15 , 7) ); echo "<h1>Manual access to each element</h1>"; echo $shop[0][0]." costs ".$shop[0][1]." and you get ".$shop[0][2]."<br />"; echo $shop[1][0]." costs ".$shop[1][1]." and you get ".$shop[1][2]."<br />"; echo $shop[2][0]." costs ".$shop[2][1]." and you get ".$shop[2][2]."<br />"; echo "<h1>Using loops to display array elements</h1>"; echo "<ol>"; for ($row = 0; $row < 3; $row++) { echo "<li><b>The row number $row</b>"; echo "<ul>"; for ($col = 0; $col < 3; $col++) { echo "<li>".$shop[$row][$col]."</li>"; } echo "</ul>"; echo "</li>"; } echo "</ol>";
based on 0H7Iv
Output for 4.3.0 - 7.1.0
<h1>Manual access to each element</h1>rose costs 1.25 and you get 15<br />daisy costs 0.75 and you get 25<br />orchid costs 1.15 and you get 7<br /><h1>Using loops to display array elements</h1><ol><li><b>The row number 0</b><ul><li>rose</li><li>1.25</li><li>15</li></ul></li><li><b>The row number 1</b><ul><li>daisy</li><li>0.75</li><li>25</li></ul></li><li><b>The row number 2</b><ul><li>orchid</li><li>1.15</li><li>7</li></ul></li></ol>