3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tests = array(array(0, .1), array(1, 'foo'), array(.24, -.25), array(3, 3), array('foo', 'bar'), array(-0, 0.1), array(90, -90), array(0, 0), array(1, 1)); foreach ($tests as $test) { echo "Raw: {$test[0]} -vs- {$test[1]} , "; $nums = array((float)$test[0],(float)$test[1]); // force input values to float values echo "FloatVals: {$nums[0]} -vs- {$nums[1]} , "; $nums = array_filter($nums, function($v){ return $v > 0;}); // check if greater than 0 if (empty($nums)) { $price = 'error'; //use die(), but I won't for demonstration } else { $price = min($nums); // declare lowest qualifying price } echo "Output: $price\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
Raw: 0 -vs- 0.1 , FloatVals: 0 -vs- 0.1 , Output: 0.1 Raw: 1 -vs- foo , FloatVals: 1 -vs- 0 , Output: 1 Raw: 0.24 -vs- -0.25 , FloatVals: 0.24 -vs- -0.25 , Output: 0.24 Raw: 3 -vs- 3 , FloatVals: 3 -vs- 3 , Output: 3 Raw: foo -vs- bar , FloatVals: 0 -vs- 0 , Output: error Raw: 0 -vs- 0.1 , FloatVals: 0 -vs- 0.1 , Output: 0.1 Raw: 90 -vs- -90 , FloatVals: 90 -vs- -90 , Output: 90 Raw: 0 -vs- 0 , FloatVals: 0 -vs- 0 , Output: error Raw: 1 -vs- 1 , FloatVals: 1 -vs- 1 , Output: 1

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:
121.83 ms | 406 KiB | 5 Q