3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SimDB { private static $count = 0; public static function mysqli_fetch_array($result) { if (self::$count < 10) { self::$count++; return "Row" . self::$count; } else { return false; } } public static function reset() { self::$count = 0; } } $result1 = ""; // This is simulated, so not an actual result set resource while ($row1 = SimDB::mysqli_fetch_array($result1)); echo "Value of \$row1 => $row1\n\n"; echo "Actually store all the results\n"; SimDB::reset(); while ($row1[] = SimDB::mysqli_fetch_array($result1)); var_dump($row1); echo "\n\n How you would actually use a while() loop\n\n"; SimDB::reset(); while ($row = SimDB::mysqli_fetch_array($result1)) { echo "Row = $row\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
Value of $row1 => Actually store all the results Deprecated: Automatic conversion of false to array is deprecated in /in/Z3Q3i on line 29 array(11) { [0]=> string(4) "Row1" [1]=> string(4) "Row2" [2]=> string(4) "Row3" [3]=> string(4) "Row4" [4]=> string(4) "Row5" [5]=> string(4) "Row6" [6]=> string(4) "Row7" [7]=> string(4) "Row8" [8]=> string(4) "Row9" [9]=> string(5) "Row10" [10]=> bool(false) } How you would actually use a while() loop Row = Row1 Row = Row2 Row = Row3 Row = Row4 Row = Row5 Row = Row6 Row = Row7 Row = Row8 Row = Row9 Row = Row10

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
19.9 ms | 402 KiB | 8 Q