3v4l.org

run code in 300+ PHP versions simultaneously
<?php ini_set('precision',32); setlocale(LC_MONETARY, 'en_US'); $deal = array( array( 'amt' => 1350, 'rate' => .75, 'lod' => 47 ), array( 'amt' => 990, 'rate' => .75, 'lod' => 27 ), array( 'amt' => 4180, 'rate' => .75, 'lod' => 65 ), array( 'amt' => 2370, 'rate' => .75, 'lod' => 26 ) ); foreach ($deal as $value) { $fee = (($value['amt'] / 1000) * $value['rate']) * $value['lod']; var_dump($fee); echo 'money_format: ' . money_format('%.2n', (float) $fee) . PHP_EOL; echo 'number_format: ' . number_format($fee, 2) . PHP_EOL . PHP_EOL; }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.4, 8.3.6 - 8.3.7
float(47.587500000000006) Fatal error: Uncaught Error: Call to undefined function money_format() in /in/ue0Th:30 Stack trace: #0 {main} thrown in /in/ue0Th on line 30
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 float(47.587500000000006) Fatal error: Uncaught Error: Call to undefined function money_format() in /in/ue0Th:30 Stack trace: #0 {main} thrown in /in/ue0Th on line 30
Process exited with code 255.
Output for 7.4.0 - 7.4.33
float(47.587500000000005684341886080801) Deprecated: Function money_format() is deprecated in /in/ue0Th on line 30 money_format: $47.59 number_format: 47.59 float(20.04749999999999943156581139192) Deprecated: Function money_format() is deprecated in /in/ue0Th on line 30 money_format: $20.05 number_format: 20.05 float(203.77499999999997726263245567679) Deprecated: Function money_format() is deprecated in /in/ue0Th on line 30 money_format: $203.77 number_format: 203.78 float(46.215000000000003410605131648481) Deprecated: Function money_format() is deprecated in /in/ue0Th on line 30 money_format: $46.22 number_format: 46.22
Output for 5.6.0 - 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
float(47.587500000000005684341886080801) money_format: $47.59 number_format: 47.59 float(20.04749999999999943156581139192) money_format: $20.05 number_format: 20.05 float(203.77499999999997726263245567679) money_format: $203.77 number_format: 203.78 float(46.215000000000003410605131648481) money_format: $46.22 number_format: 46.22

preferences:
180.99 ms | 403 KiB | 302 Q