3v4l.org

run code in 300+ PHP versions simultaneously
<?php function price_format($num,$type = 1){ $num_full = number_format($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, strpos($num_full, "."))."/-"; } else { $thecash = "₹".$num.substr($num_full, -3, strpos($num_full, "."))."/-"; } return $thecash; // writes the final format where $currency is the currency symbol. } } echo price_format(1)."<br />"; echo price_format(10)."<br />"; 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.0100.01117.70
8.4.130.0120.00917.94
8.4.120.0090.01020.46
8.4.110.0120.00718.95
8.4.100.0120.00817.69
8.4.90.0130.00819.72
8.4.80.0130.00717.86
8.4.70.0090.00317.67
8.4.60.0140.00817.59
8.4.50.0050.00418.78
8.4.40.0070.00317.65
8.4.30.0170.00020.64
8.4.20.0100.00717.81
8.4.10.0050.00326.11
8.3.270.0110.00816.56
8.3.260.0040.00416.59
8.3.250.0120.00619.07
8.3.240.0110.00516.85
8.3.230.0100.00916.66
8.3.220.0070.01117.19
8.3.210.0090.00316.73
8.3.200.0120.00716.59
8.3.190.0110.00817.29
8.3.180.0110.00817.27
8.3.170.0070.00720.69
8.3.160.0060.01217.06
8.3.150.0070.01320.85
8.3.140.0080.00816.60
8.3.130.0040.00817.46
8.3.120.0060.00319.18
8.3.110.0080.00016.38
8.3.100.0000.00924.06
8.3.90.0140.00426.77
8.3.80.0120.00217.29
8.3.70.0140.00716.63
8.3.60.0100.01018.55
8.3.50.0110.00724.57
8.3.40.0040.01118.97
8.3.30.0130.00318.94
8.3.20.0050.00324.18
8.3.10.0080.00024.66
8.3.00.0070.00026.16
8.2.290.0130.00620.26
8.2.280.0110.00816.88
8.2.270.0040.01117.08
8.2.260.0080.00818.73
8.2.250.0040.00418.21
8.2.240.0060.00318.94
8.2.230.0060.00320.94
8.2.220.0030.00737.54
8.2.210.0030.00526.77
8.2.200.0030.00616.63
8.2.190.0100.00616.63
8.2.180.0070.01425.92
8.2.170.0090.00618.95
8.2.160.0060.00922.96
8.2.150.0040.00425.66
8.2.140.0080.00024.66
8.2.130.0130.00326.16
8.2.120.0040.00421.06
8.2.110.0050.00519.46
8.2.100.0040.00818.03
8.2.90.0040.00420.72
8.2.80.0040.00418.90
8.2.70.0030.00617.50
8.2.60.0030.00517.61
8.2.50.0030.00518.05
8.2.40.0000.00718.03
8.2.30.0040.00418.09
8.2.20.0000.00718.09
8.2.10.0040.00419.30
8.2.00.0060.00319.30
8.1.330.0120.00723.58
8.1.320.0130.00616.33
8.1.310.0080.00816.57
8.1.300.0120.00416.10
8.1.290.0030.00718.88
8.1.280.0110.00425.92
8.1.270.0050.00323.96
8.1.260.0000.00726.35
8.1.250.0060.00328.09
8.1.240.0030.00622.78
8.1.230.0090.00322.20
8.1.220.0040.00417.89
8.1.210.0050.00318.77
8.1.200.0060.00317.36
8.1.190.0040.00417.35
8.1.180.0000.00818.10
8.1.170.0040.00418.61
8.1.160.0040.00418.89
8.1.150.0000.00718.86
8.1.140.0070.00018.90
8.1.130.0000.00920.19
8.1.120.0030.00517.57
8.1.110.0040.00417.43
8.1.100.0000.00717.43
8.1.90.0030.00617.59
8.1.80.0000.00917.55
8.1.70.0000.00717.57
8.1.60.0000.00717.69
8.1.50.0030.00617.53
8.1.40.0020.00517.56
8.1.30.0000.00817.66
8.1.20.0060.00317.57
8.1.10.0040.00417.64
8.1.00.0040.00417.58
8.0.300.0040.00418.78
8.0.290.0050.00516.88
8.0.280.0000.00718.45
8.0.270.0030.00518.10
8.0.260.0000.00618.51
8.0.250.0050.00216.98
8.0.240.0000.00817.07
8.0.230.0070.00017.06
8.0.220.0000.00816.88
8.0.210.0030.00316.96
8.0.200.0040.00416.95
8.0.190.0070.00017.02
8.0.180.0040.00416.98
8.0.170.0080.00017.04
8.0.160.0030.00316.97
8.0.150.0030.00516.91
8.0.140.0060.00316.95
8.0.130.0030.00313.45
8.0.120.0040.00416.95
8.0.110.0040.00416.82
8.0.100.0040.00416.88
8.0.90.0000.00717.02
8.0.80.0040.01016.86
8.0.70.0040.00416.81
8.0.60.0030.00517.01
8.0.50.0050.00216.97
8.0.30.0150.00917.03
8.0.20.0090.00917.40
8.0.10.0080.01117.40
8.0.00.0120.00917.40
7.4.330.0000.00516.84
7.4.320.0000.00716.65
7.4.300.0030.00316.48
7.4.290.0080.00016.59
7.4.280.0070.00016.57
7.4.270.0040.00416.59
7.4.260.0050.00013.29
7.4.250.0050.00316.63
7.4.240.0070.00016.52
7.4.230.0030.00616.71
7.4.220.0030.00316.74
7.4.210.0080.00816.71
7.4.200.0050.00316.62
7.4.150.0150.00317.40
7.4.140.0070.01117.40
7.4.130.0050.01317.40
7.4.120.0120.00717.40
7.4.110.0090.00917.40
7.4.100.0000.01717.40
7.4.90.0060.01217.40
7.4.80.0070.01017.40
7.4.70.0110.00717.40
7.4.60.0110.00717.40
7.4.50.0140.00917.40
7.4.40.0060.00917.40
7.4.30.0030.01517.40
7.4.20.0150.01117.40
7.4.10.0110.00617.40
7.4.00.0100.00717.40
7.3.330.0000.00716.41
7.3.320.0040.00413.46
7.3.310.0000.00716.32
7.3.300.0000.00816.38
7.3.290.0080.00816.44
7.3.270.0110.00717.40
7.3.260.0160.00017.40
7.3.250.0150.00317.40
7.3.240.0060.01217.40
7.3.230.0100.00717.40
7.3.220.0140.00317.40
7.3.210.0120.00617.40
7.3.200.0100.00617.40
7.3.190.0110.00717.40
7.3.180.0130.00517.40
7.3.170.0030.01317.40
7.3.160.0110.00717.40
7.3.150.0140.01117.40
7.3.140.0080.00817.40
7.3.130.0090.00917.40
7.3.120.0060.00917.40
7.3.110.0110.01117.40
7.3.100.0060.01217.40
7.3.90.0100.00717.40
7.3.80.0060.01017.40
7.3.70.0130.00317.40
7.3.60.0140.00917.40
7.3.50.0070.01517.40
7.3.40.0080.01317.40
7.3.30.0060.01217.40
7.3.20.0100.00717.40
7.3.10.0150.00417.40
7.3.00.0070.01017.40

preferences:
31.55 ms | 403 KiB | 5 Q