3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function getArray() { echo "getArray was called.</br>"; return array(1,2,3,4,5,6); } // test for assigning the array return in a variable echo "1st test</br>"; $arr = getArray(); foreach ($arr as $val) { echo $val; } echo "</br></br>2nd test</br>"; // test for getting the array inside the foreach iterator foreach (getArray() as $val) { echo $val; }
Output for 4.3.0 - 7.1.7
1st test</br>getArray was called.</br>123456</br></br>2nd test</br>getArray was called.</br>123456