3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $someArray = array("key1" => "value1", "key2" => "value2", "key3" => "value3", "key4" => "value4"); $len = count($someArray); $i = 0; foreach($someArray AS $key => $value) { if($i == $len - 1) { echo "This is the last line!"; } else { echo "This is line $i\n"; } $i++; }
Output for 4.3.0 - 7.1.0
This is line 0 This is line 1 This is line 2 This is the last line!