3v4l.org

run code in 300+ PHP versions simultaneously
<?php function fee($amount) { $ourFeePct = .05; // %5 $stripeFeePct = .029; // 2.9% $stripeFeeFixed = 30; //30 cents $ourFee = (int) $amount * $ourFeePct; //5 cents on the dollar. $total = (int) ($amount + $ourFee + $stripeFeeFixed) /(1 - $stripeFeePct); $stripe = ($total - $amount) - $ourFee;//stripes cut return [$ourFee,$total,$stripe]; } $amt = 5000; // $50 in cents. list($fee,$total,$stripe) = fee($amt); printf('amount to be paid to user B %d'.PHP_EOL,$amt); printf('amount to be charged to user A %d'.PHP_EOL,$total); printf('our cut %d'.PHP_EOL,$fee); printf('stripes cut %d'.PHP_EOL,$stripe);
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 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
amount to be paid to user B 5000 amount to be charged to user A 5437 our cut 250 stripes cut 187

preferences:
99.55 ms | 1495 KiB | 4 Q