3v4l.org

run code in 300+ PHP versions simultaneously
<?php function price_format($num,$type = 1){ $num_full = number_format((float)$num,2,'.',''); if (strpos($num, '.') !== false) { $num = substr($num_full, 0, strpos($num_full, ".")); } if($type == 1){ // '₹10,00,000.00/-' $explrestunits = "" ; if(strlen($num)>3) { $lastthree = substr($num, strlen($num)-3, strlen($num)); $restunits = substr($num, 0, strlen($num)-3); // extracts the last three digits $restunits = (strlen($restunits)%2 == 1)?"0".$restunits:$restunits; // explodes the remaining digits in 2's formats, adds a zero in the beginning to maintain the 2's grouping. $expunit = str_split($restunits, 2); for($i=0; $i<sizeof($expunit); $i++) { // creates each of the 2's group and adds a comma to the end if($i==0) { $explrestunits .= (int)$expunit[$i].","; // if is first value , convert into integer } else { $explrestunits .= $expunit[$i].","; } } $thecash = "₹".$explrestunits.$lastthree.substr($num_full, -3)."/-"; } else { $thecash = "₹".$num.substr($num_full, -3)."/-"; } return $thecash; // writes the final format where $currency is the currency symbol. } } echo price_format(1).PHP_EOL; echo price_format(10).PHP_EOL; echo price_format(84289.35);

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.4.140.0110.01117.44
8.4.130.0120.00917.48
8.4.120.0110.00924.12
8.4.110.0120.00720.66
8.4.100.0070.00217.80
8.4.90.0100.00720.75
8.4.80.0120.00817.91
8.4.70.0100.01017.95
8.4.60.0130.00817.55
8.4.50.0110.00519.32
8.4.40.0070.01417.73
8.4.30.0130.00720.33
8.4.20.0160.01018.00
8.4.10.0090.00025.93
8.3.270.0110.01016.80
8.3.260.0120.00816.72
8.3.250.0100.00918.80
8.3.240.0100.00917.03
8.3.230.0130.00716.80
8.3.220.0060.01219.18
8.3.210.0120.00816.47
8.3.200.0070.00118.77
8.3.190.0070.00116.86
8.3.180.0070.00316.62
8.3.170.0130.00618.77
8.3.160.0090.00918.56
8.3.150.0090.00920.78
8.3.140.0040.01116.88
8.3.130.0050.00318.58
8.3.120.0060.00919.08
8.3.110.0060.00916.39
8.3.100.0120.00318.40
8.3.90.0030.00726.77
8.3.80.0070.00416.38
8.3.70.0070.01516.58
8.3.60.0060.00918.33
8.3.50.0100.01024.46
8.3.40.0040.01118.96
8.3.30.0110.00718.86
8.3.20.0040.00424.18
8.3.10.0000.00824.66
8.3.00.0040.00426.16
8.2.290.0140.00420.40
8.2.280.0050.00716.63
8.2.270.0110.00717.27
8.2.260.0080.00018.93
8.2.250.0100.00016.79
8.2.240.0060.00317.16
8.2.230.0030.00520.94
8.2.220.0030.00737.54
8.2.210.0090.00026.77
8.2.200.0060.00318.29
8.2.190.0070.01416.63
8.2.180.0150.00325.92
8.2.170.0110.00418.96
8.2.160.0070.00722.96
8.2.150.0080.00625.66
8.2.140.0070.00024.66
8.2.130.0000.00826.16
8.2.120.0030.00620.61
8.2.110.0100.00021.18
8.2.100.0000.01218.03
8.2.90.0030.00619.69
8.2.80.0040.00417.97
8.2.70.0040.00417.63
8.2.60.0000.01017.75
8.2.50.0080.00018.05
8.2.40.0000.00818.47
8.2.30.0040.00418.32
8.2.20.0070.00018.19
8.2.10.0000.00719.29
8.2.00.0000.00819.50
8.1.330.0100.00822.28
8.1.320.0100.00816.38
8.1.310.0190.00016.90
8.1.300.0090.00020.21
8.1.290.0060.00330.84
8.1.280.0170.00325.92
8.1.270.0000.00724.66
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0060.00320.86
8.1.230.0100.00618.99
8.1.220.0040.00417.79
8.1.210.0000.00818.77
8.1.200.0030.00717.23
8.1.190.0030.00517.36
8.1.180.0050.00318.10
8.1.170.0030.00518.70
8.1.160.0070.00018.99
8.1.150.0040.00418.86
8.1.140.0000.00718.88
8.1.130.0030.00320.26
8.1.120.0070.00017.57
8.1.110.0030.00517.44
8.1.100.0050.00217.52
8.1.90.0040.00417.50
8.1.80.0000.00817.43
8.1.70.0070.00017.50
8.1.60.0080.00017.72
8.1.50.0040.00417.51
8.1.40.0040.00417.68
8.1.30.0080.00017.76
8.1.20.0060.00317.67
8.1.10.0030.00617.68
8.1.00.0040.00417.50
8.0.300.0000.00821.95
8.0.290.0080.00016.75
8.0.280.0000.00718.42
8.0.270.0040.00418.00
8.0.260.0000.00618.49
8.0.250.0000.00817.05
8.0.240.0000.00716.96
8.0.230.0000.00716.98
8.0.220.0080.00016.94
8.0.210.0040.00416.99
8.0.200.0030.00317.08
8.0.190.0040.00416.98
8.0.180.0040.00417.06
8.0.170.0080.00016.89
8.0.160.0000.00716.95
8.0.150.0030.00716.86
8.0.140.0040.00416.98
8.0.130.0030.00313.45
8.0.120.0000.00816.87
8.0.110.0000.00816.85
8.0.100.0050.00216.84
8.0.90.0080.00016.87
8.0.80.0060.00916.97
8.0.70.0080.00016.93
8.0.60.0070.00016.94
8.0.50.0000.00717.01
8.0.30.0070.01116.94
8.0.20.0040.01617.40
8.0.10.0310.00617.40
8.0.00.0230.01317.40
7.4.330.0030.00315.55
7.4.320.0030.00316.73
7.4.300.0000.00616.67
7.4.290.0070.00016.51
7.4.280.0080.00016.48
7.4.270.0030.00316.68
7.4.260.0050.00013.41
7.4.250.0040.00416.57
7.4.240.0030.00516.62
7.4.230.0000.00816.42
7.4.220.0050.00216.68
7.4.210.0100.00416.71
7.4.200.0040.00316.71
7.4.150.0060.01117.40
7.4.140.0200.01017.40
7.4.130.0240.00617.40
7.4.120.0440.01517.40
7.4.110.0310.00017.40
7.4.100.0210.01117.40
7.4.90.0310.00317.40
7.4.80.0200.01017.40
7.4.70.0260.00417.40
7.4.60.0180.01517.40
7.4.50.0160.01617.40
7.4.40.0350.02017.40
7.4.30.0040.01517.40
7.4.20.0060.01317.40
7.4.10.0080.01117.40
7.4.00.0030.01517.40
7.3.330.0030.00316.43
7.3.320.0070.00013.44
7.3.310.0040.00416.47
7.3.300.0030.00316.46
7.3.290.0080.00816.42
7.3.270.0120.00617.40
7.3.260.0250.01017.40
7.3.250.0180.01217.40
7.3.240.0270.01117.40
7.3.230.0200.01217.40
7.3.220.0270.00417.40
7.3.210.0130.01817.40
7.3.200.0220.01017.40
7.3.190.0260.00517.40
7.3.180.0400.00617.40
7.3.170.0260.00617.40
7.3.160.0190.01217.40
7.3.150.0120.00617.40
7.3.140.0110.00817.40
7.3.130.0130.00617.40
7.3.120.0070.01117.40
7.3.110.0070.01017.40
7.3.100.0070.01117.40
7.3.90.0070.01117.40
7.3.80.0120.01217.40
7.3.70.0040.01317.40
7.3.60.0100.00717.40
7.3.50.0080.00817.40
7.3.40.0100.00717.40
7.3.30.0110.00717.40
7.3.20.0160.00317.40
7.3.10.0120.00617.40
7.3.00.0100.00817.40

preferences:
138.06 ms | 403 KiB | 5 Q