3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = ['1', '15', '2','10', 4]; foreach ($array as $v) { if (!isset($max1)) { $max1 = $v; } elseif ($max1 < $v) { $max2 = $max1; $max1 = $v; } elseif (!isset($max2) || $max2 < $v) { $max2 = $v; } } var_dump( $max1 ?? 'Never declared', $max2 ?? 'Never declared' );
Output for git.master, git.master_jit
string(2) "15" string(2) "10"

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:
43.9 ms | 839 KiB | 4 Q