3v4l.org

run code in 300+ PHP versions simultaneously
<?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>";
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
<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>

preferences:
226.99 ms | 407 KiB | 326 Q