3v4l.org

run code in 150+ 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 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
1st test</br>getArray was called.</br>123456</br></br>2nd test</br>getArray was called.</br>123456