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 = '000000004575030'; $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.0160.00016.75
8.3.50.0080.00818.17
8.3.40.0130.00318.65
8.3.30.0090.00618.53
8.3.20.0000.00821.94
8.3.10.0080.00023.61
8.3.00.0050.00319.56
8.2.180.0070.00718.42
8.2.170.0110.00422.96
8.2.160.0110.00420.27
8.2.150.0090.00024.18
8.2.140.0040.00424.66
8.2.130.0070.01026.16
8.2.120.0070.00019.89
8.2.110.0060.00321.07
8.2.100.0070.00717.72
8.2.90.0000.00819.35
8.2.80.0040.00418.00
8.2.70.0040.00417.75
8.2.60.0000.00817.93
8.2.50.0050.00518.10
8.2.40.0070.00020.64
8.2.30.0000.00821.04
8.2.20.0060.00318.04
8.2.10.0050.00318.26
8.2.00.0040.00418.24
8.1.280.0100.01025.92
8.1.270.0040.00419.05
8.1.260.0110.00726.35
8.1.250.0040.01128.09
8.1.240.0040.00422.17
8.1.230.0070.00322.07
8.1.220.0080.00017.80
8.1.210.0050.00318.77
8.1.200.0070.00317.48
8.1.190.0030.00617.35
8.1.180.0000.00818.10
8.1.170.0030.00618.71
8.1.160.0070.00019.09
8.1.150.0060.00320.70
8.1.140.0030.00519.69
8.1.130.0030.00320.78
8.1.120.0000.00717.53
8.1.110.0030.00517.58
8.1.100.0000.00717.51
8.1.90.0040.00417.51
8.1.80.0040.00417.52
8.1.70.0070.00317.59
8.1.60.0000.00817.55
8.1.50.0020.00517.50
8.1.40.0040.00417.43
8.1.30.0000.00717.74
8.1.20.0050.00317.59
8.1.10.0040.00417.60
8.1.00.0000.00817.41
8.0.300.0040.00418.77
8.0.290.0030.00516.75
8.0.280.0000.00718.56
8.0.270.0030.00317.45
8.0.260.0000.00619.04
8.0.250.0070.00017.05
8.0.240.0030.00517.06
8.0.230.0030.00316.91
8.0.220.0000.00616.89
8.0.210.0000.00716.89
8.0.200.0030.00316.99
8.0.190.0000.00917.00
8.0.180.0000.00716.95
8.0.170.0040.00417.03
8.0.160.0030.00516.82
8.0.150.0050.00316.93
8.0.140.0000.00716.97
8.0.130.0000.00613.34
8.0.120.0040.00416.84
8.0.110.0050.00217.00
8.0.100.0050.00216.88
8.0.90.0040.00416.83
8.0.80.0130.00716.89
8.0.70.0000.00816.95
8.0.60.0020.00517.04
8.0.50.0050.00217.00
8.0.30.0090.00917.20
8.0.20.0150.01417.42
8.0.10.0040.00417.08
8.0.00.0120.00617.06
7.4.330.0000.00515.55
7.4.320.0000.00616.57
7.4.300.0030.00316.67
7.4.290.0030.00316.54
7.4.280.0000.00916.58
7.4.270.0030.00316.66
7.4.260.0000.01016.55
7.4.250.0080.00016.64
7.4.240.0030.00616.60
7.4.230.0080.00016.79
7.4.220.0100.01016.76
7.4.210.0060.01016.72
7.4.200.0050.00316.47
7.4.160.0090.00616.55
7.4.150.0100.00917.40
7.4.140.0080.01117.86
7.4.130.0220.00416.67
7.4.120.0130.00816.54
7.4.110.0140.00316.45
7.4.100.0150.00616.52
7.4.90.0160.00616.70
7.4.80.0110.00619.39
7.4.70.0090.01316.62
7.4.60.0060.01016.63
7.4.50.0030.01016.57
7.4.40.0080.00916.63
7.4.30.0170.00616.47
7.4.00.0000.01414.84
7.3.330.0050.00013.21
7.3.320.0000.00513.46
7.3.310.0000.00716.45
7.3.300.0000.00716.32
7.3.290.0060.00916.47
7.3.280.0090.00816.43
7.3.270.0090.01017.40
7.3.260.0090.01016.45
7.3.250.0150.00416.47
7.3.240.0110.00616.42
7.3.230.0090.00916.30
7.3.210.0130.00316.55
7.3.200.0100.01316.46
7.3.190.0090.00916.32
7.3.180.0000.01616.48
7.3.170.0100.00616.70
7.3.160.0130.00316.55
7.3.10.0030.01216.73
7.3.00.0070.00716.31
7.2.330.0200.00016.53
7.2.320.0100.01316.48
7.2.310.0130.00316.81
7.2.300.0060.01216.82
7.2.290.0060.01216.79
7.2.130.0060.00816.67
7.2.120.0090.00616.84
7.2.110.0040.01216.56
7.2.100.0000.01216.84
7.2.90.0090.00617.01
7.2.80.0030.00916.79
7.2.70.0030.01017.02
7.2.60.0040.00716.88
7.2.50.0040.00716.92
7.2.40.0030.00916.96
7.2.30.0030.01316.64
7.2.20.0110.00316.94
7.2.10.0100.00316.85
7.2.00.0070.01016.99
7.1.250.0030.01215.94
7.1.200.0000.01415.72
7.1.70.0040.00916.62
7.1.60.0700.02333.17
7.1.50.0800.00333.04
7.1.40.0830.00732.49
7.1.30.0900.01732.86
7.1.20.0730.01332.72
7.1.10.0530.00714.78
7.1.00.1000.00715.04
7.0.200.0670.01014.94
7.0.190.0670.01015.02
7.0.180.0970.01014.46
7.0.170.0930.00714.49
7.0.160.0700.01314.33
7.0.150.0630.00714.48
7.0.140.0830.00714.53
7.0.130.0900.01014.65
7.0.120.0670.01314.71
7.0.110.0530.01314.56
7.0.100.0830.01014.46
7.0.90.0730.00714.50
7.0.80.0700.01014.77
7.0.70.0700.00714.27
7.0.60.0770.01014.35
7.0.50.0970.01314.46
7.0.40.0730.01014.62
7.0.30.0870.00714.61
7.0.20.2200.00714.86
7.0.10.0600.00714.77
7.0.00.0800.00314.65

preferences:
41.18 ms | 400 KiB | 5 Q