3v4l.org

run code in 300+ 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, 7.1.0 - 7.1.23, 7.2.0 - 7.2.33, 7.3.16 - 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.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
22

preferences:
102.19 ms | 1436 KiB | 4 Q