3v4l.org

run code in 500+ PHP versions simultaneously
<?php $priceChart = (object) [ 'Monday' => function($price) { return (int) $price / 2; }, 'Wednesday' => function($price) { return (int) $price * 1.1; }, 'Friday' => function($price) { return (int) $price > 200 ? (int) $price - 20 : (int) $price; } ]; $price = 20.00; $currentDay = 'Wednesday'; $newPrice = isset($priceChart->{$currentDay}) ? call_user_func_array($priceChart->{$currentDay}, [$price]) : $price; echo $newPrice;
Output for 5.6.38 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.34, 8.3.0 - 8.3.33, 8.4.1 - 8.4.26, 8.5.0 - 8.5.9
22

preferences:
33.17 ms | 1136 KiB | 8 Q