3v4l.org

run code in 300+ PHP versions simultaneously
<?php function discount($cart){ $sum = array_sum($cart); if($sum >= 100) return 15; else if(count($cart) >= 3 and (isset($cart['A']) or isset($cart['B']))) return 10; else if(count($cart) >= 3) return 5; else return 0; } $carts = [ // product => price ['A' => 15, 'B' => 25], // no discount ['D' => 15, 'E' => 25, 'F' => 50], // any 3 ['A' => 15, 'B' => 25, 'D' => 35], // any 2 + 1 special ['A' => 15, 'B' => 25, 'C' => 50, 'D' => 75], // over amount x ]; foreach($carts as $cart){ echo (string)discount($cart), "\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
0 5 10 15

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:
18.61 ms | 401 KiB | 8 Q