3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getValorDecimal($linhaDados, $posicaoInicial, $tamanhoCampo, $decimal = 0) { $retorno = ""; $retorno = substr($linhaDados,$posicaoInicial-1 , $tamanhoCampo ); $retorno = trim($retorno); $retorno = str_replace(".","", $retorno); $retorno = str_replace(",",".", $retorno); if ($retorno != "") { $retorno = ltrim($retorno,'0'); if ($retorno == '') { $retorno = '0'; } if ($retorno != 0 && $decimal != 0) { $divisor = str_pad('1', $decimal + 1, '0'); $retorno = round($retorno / $divisor , $decimal); } } return $retorno; } function getValor2DecAlignRight($dado, $size, $completa = "0"){ $new = ""; if ($dado != ''){ $new= number_format($dado,2,'',''); $new = str_pad(substr($new,0,$size), $size, $completa, STR_PAD_LEFT); }else{ $new = str_pad(substr($new,0,$size), $size, $completa, STR_PAD_LEFT); } return $new; } $currentLine = '000000004575000'; $valor = getValorDecimal($currentLine, 1, 15, 2); var_dump( $valor ); $valor = getValor2DecAlignRight((string) $valor, 15); var_dump( $valor );

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.3.60.0190.00016.50
8.3.50.0030.01016.13
8.3.40.0140.00018.71
8.3.30.0060.01018.55
8.3.20.0050.00221.85
8.3.10.0040.00423.71
8.3.00.0000.00819.64
8.2.180.0070.00718.18
8.2.170.0120.00322.96
8.2.160.0090.00920.57
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0030.00620.63
8.2.120.0000.00726.35
8.2.110.0030.00619.14
8.2.100.0110.00017.91
8.2.90.0050.00319.22
8.2.80.0080.00017.97
8.2.70.0030.00617.75
8.2.60.0000.00818.05
8.2.50.0000.00818.10
8.2.40.0020.00520.59
8.2.30.0000.00821.10
8.2.20.0000.00718.19
8.2.10.0040.00418.20
8.2.00.0000.00818.22
8.1.280.0130.00625.92
8.1.270.0040.00420.79
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0060.00322.13
8.1.230.0080.00323.99
8.1.220.0040.00417.74
8.1.210.0030.00518.77
8.1.200.0070.00317.23
8.1.190.0040.00417.23
8.1.180.0030.00618.10
8.1.170.0080.00418.68
8.1.160.0040.00419.00
8.1.150.0060.00320.65
8.1.140.0040.00419.62
8.1.130.0040.00420.73
8.1.120.0040.00417.56
8.1.110.0050.00217.56
8.1.100.0000.00717.55
8.1.90.0000.00717.52
8.1.80.0080.00017.57
8.1.70.0000.01017.44
8.1.60.0050.00317.67
8.1.50.0040.00417.59
8.1.40.0000.00817.48
8.1.30.0000.00817.57
8.1.20.0050.00317.64
8.1.10.0000.00717.55
8.1.00.0000.00817.54
8.0.300.0040.00418.77
8.0.290.0050.00216.75
8.0.280.0030.00518.59
8.0.270.0070.00017.25
8.0.260.0030.00318.96
8.0.250.0040.00417.00
8.0.240.0030.00617.05
8.0.230.0050.00216.99
8.0.220.0000.00716.92
8.0.210.0070.00016.86
8.0.200.0030.00317.04
8.0.190.0040.00416.95
8.0.180.0070.00017.02
8.0.170.0000.00816.84
8.0.160.0000.00717.00
8.0.150.0000.00716.82
8.0.140.0000.00716.92
8.0.130.0030.00313.40
8.0.120.0000.00716.89
8.0.110.0040.00416.88
8.0.100.0000.00716.75
8.0.90.0000.00716.77
8.0.80.0070.01016.98
8.0.70.0000.00717.03
8.0.60.0000.00716.77
8.0.50.0000.00816.94
8.0.30.0130.00717.18
8.0.20.0130.00817.40
8.0.10.0040.00416.89
8.0.00.0120.00616.62
7.4.330.0000.00515.55
7.4.320.0060.00016.60
7.4.300.0070.00016.57
7.4.290.0000.00816.53
7.4.280.0040.00416.63
7.4.270.0040.00416.70
7.4.260.0000.00816.66
7.4.250.0050.00316.49
7.4.240.0000.00716.49
7.4.230.0000.00716.57
7.4.220.0120.00616.66
7.4.210.0140.00016.77
7.4.200.0030.00316.76
7.4.160.0040.01216.57
7.4.150.0090.00917.40
7.4.140.0110.00817.86
7.4.130.0120.01316.59
7.4.120.0120.00916.56
7.4.110.0130.00716.76
7.4.100.0100.00716.46
7.4.90.0040.01216.46
7.4.80.0090.00919.39
7.4.70.0100.00716.55
7.4.60.0090.00616.63
7.4.50.0030.01316.65
7.4.40.0070.01016.64
7.4.30.0000.01716.56
7.4.00.0060.00615.14
7.3.330.0020.00213.23
7.3.320.0050.00013.28
7.3.310.0040.00416.32
7.3.300.0040.00416.32
7.3.290.0050.01116.44
7.3.280.0080.01016.41
7.3.270.0120.00917.40
7.3.260.0140.00916.75
7.3.250.0150.00216.49
7.3.240.0100.00716.57
7.3.230.0080.00916.40
7.3.210.0100.00716.45
7.3.200.0090.01016.52
7.3.190.0070.01316.34
7.3.180.0060.01016.75
7.3.170.0100.00616.54
7.3.160.0070.01016.64
7.2.330.0100.00716.80
7.2.320.0120.00916.81
7.2.310.0070.01016.89
7.2.300.0110.00716.77
7.2.290.0100.00616.70
7.2.60.0000.01716.86
7.2.50.0000.01316.98
7.1.200.0000.01315.86
7.1.70.0000.00717.31
7.1.60.0000.01017.25
7.1.50.0070.00317.03
7.1.40.0060.00616.73
7.1.30.0000.01016.73
7.1.20.0040.00716.73
7.1.10.0000.00816.73
7.1.00.0030.00616.73
7.0.200.0040.00416.85
7.0.190.0050.00516.76
7.0.180.0000.00816.73
7.0.170.0050.00316.73
7.0.160.0000.00916.73
7.0.150.0000.00916.73
7.0.140.0040.00816.73
7.0.130.0060.00316.73
7.0.120.0000.00716.73
7.0.110.0000.00816.73
7.0.100.0050.00316.73
7.0.90.0040.00416.73
7.0.80.0040.00416.73
7.0.70.0000.00816.73
7.0.60.0000.00716.73
7.0.50.0000.00716.73
7.0.40.0000.00716.73
7.0.30.0000.00716.73
7.0.20.0000.00816.73
7.0.10.0070.00416.73
7.0.00.0000.00716.73

preferences:
51.37 ms | 400 KiB | 5 Q