3v4l.org

run code in 300+ PHP versions simultaneously
<?php // convert decimal to base 2 without using base_convert or printf $base = 2; $decnum = 23; $num = 23; $stack = array(); while( $num > 0) { $arr[] = $num % $base; // store remainder in array $num = floor($num/$base); // no integer division } var_dump($arr); $wrong = join('',$arr); var_dump($wrong); $cat = join('',array_reverse($arr)); var_dump($cat); printf("%b\n",$decnum); echo base_convert(23,10,2),"\n"; // now using the stack while( $decnum > 0) { array_push($stack,($decnum % $base)); // store remainder on stack $decnum = floor($decnum/$base); // no integer division } while($stack) { echo array_pop($stack); } echo "\n"; // per manual: Note: If you use array_push() to add one element to the array it's better to use $array[] = // because in that way there is no overhead of calling a function. $decnum = 23; while( $decnum > 0) { $stack[] = $decnum % $base; // store remainder on stack $decnum = floor($decnum/$base); // no integer division } while($stack) { echo array_pop($stack); } echo "\n";

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.0110.00418.55
8.3.50.0130.00622.05
8.3.40.0080.00818.83
8.3.30.0110.00319.09
8.3.20.0040.01120.29
8.3.10.0050.00322.08
8.3.00.0040.00422.55
8.2.180.0070.01416.50
8.2.170.0110.01122.96
8.2.160.0100.00320.38
8.2.150.0030.00624.18
8.2.140.0000.00824.66
8.2.130.0030.01026.16
8.2.120.0040.00419.36
8.2.110.0040.00719.37
8.2.100.0120.00017.88
8.2.90.0000.00719.34
8.2.80.0030.00517.97
8.2.70.0090.00017.75
8.2.60.0040.00418.16
8.2.50.0030.00618.07
8.2.40.0000.00818.22
8.2.30.0050.00218.11
8.2.20.0070.00017.72
8.2.10.0040.00417.81
8.2.00.0080.00017.68
8.1.280.0070.00725.92
8.1.270.0080.00022.32
8.1.260.0070.00026.35
8.1.250.0040.00428.09
8.1.240.0060.00322.33
8.1.230.0070.00319.12
8.1.220.0040.00417.91
8.1.210.0040.00418.77
8.1.200.0090.00017.36
8.1.190.0000.00817.22
8.1.180.0030.00618.72
8.1.170.0000.00818.52
8.1.160.0030.00622.05
8.1.150.0040.00418.61
8.1.140.0000.00717.41
8.1.130.0050.00217.80
8.1.120.0030.00317.43
8.1.110.0080.00017.53
8.1.100.0070.00017.38
8.1.90.0040.00417.50
8.1.80.0000.00717.44
8.1.70.0000.00717.36
8.1.60.0060.00617.63
8.1.50.0050.00317.43
8.1.40.0000.00717.50
8.1.30.0040.00417.61
8.1.20.0080.00017.61
8.1.10.0000.00817.54
8.1.00.0050.00317.37
8.0.300.0070.00018.77
8.0.290.0040.00416.75
8.0.280.0000.00718.44
8.0.270.0000.01017.23
8.0.260.0090.00016.88
8.0.250.0030.00317.04
8.0.240.0040.00416.93
8.0.230.0000.00917.02
8.0.220.0000.00716.94
8.0.210.0000.00716.96
8.0.200.0000.00617.08
8.0.190.0050.00216.91
8.0.180.0030.00317.00
8.0.170.0050.00216.97
8.0.160.0040.00417.05
8.0.150.0040.00416.80
8.0.140.0060.00316.80
8.0.130.0000.00513.39
8.0.120.0030.00516.96
8.0.110.0000.00716.85
8.0.100.0040.00416.97
8.0.90.0000.00916.85
8.0.80.0090.00616.94
8.0.70.0040.00416.94
8.0.60.0070.00016.75
8.0.50.0040.00416.91
8.0.30.0140.00617.04
8.0.20.0070.01217.40
8.0.10.0000.00717.11
8.0.00.0080.01216.77
7.4.330.0030.00315.00
7.4.320.0000.00816.56
7.4.300.0060.00016.55
7.4.290.0000.00616.40
7.4.280.0030.00316.45
7.4.270.0000.00716.62
7.4.260.0000.00716.58
7.4.250.0030.00316.37
7.4.240.0040.00316.49
7.4.230.0050.00316.54
7.4.220.0040.01516.64
7.4.210.0110.00516.51
7.4.200.0070.00016.66
7.4.190.0080.00016.46
7.4.160.0120.00616.58
7.4.150.0060.01617.40
7.4.140.0070.01017.86
7.4.130.0090.01016.53
7.4.120.0110.00816.52
7.4.110.0040.01316.51
7.4.100.0040.02016.53
7.4.90.0160.00916.48
7.4.80.0080.00819.39
7.4.70.0030.01316.51
7.4.60.0060.01116.64
7.4.50.0000.00816.52
7.4.40.0060.01022.77
7.4.30.0110.00516.46
7.4.10.0070.01116.45
7.4.00.0090.00915.88
7.3.330.0050.00013.24
7.3.320.0000.00513.31
7.3.310.0030.00316.48
7.3.300.0030.00316.48
7.3.290.0080.00716.44
7.3.280.0070.01016.43
7.3.270.0110.00717.40
7.3.260.0110.00616.54
7.3.250.0080.00916.54
7.3.240.0090.01316.48
7.3.230.0090.01216.67
7.3.210.0040.01316.31
7.3.200.0090.00919.39
7.3.190.0100.00716.29
7.3.180.0100.01316.36
7.3.170.0030.01316.73
7.3.160.0100.00716.49
7.3.130.0150.00416.29
7.3.120.0110.00915.93
7.3.110.0080.00916.50
7.3.100.0090.01016.42
7.3.90.0050.00816.44
7.3.80.0030.01316.41
7.3.70.0110.00816.37
7.3.60.0080.01116.39
7.3.50.0070.01016.42
7.3.40.0100.00816.42
7.3.30.0040.01216.40
7.3.20.0060.01317.33
7.3.10.0110.00917.20
7.3.00.0080.01017.29
7.2.330.0030.01516.84
7.2.320.0030.01316.87
7.2.310.0060.01016.78
7.2.300.0090.00916.73
7.2.290.0050.01116.88
7.2.260.0070.01116.55
7.2.250.0070.01516.52
7.2.240.0070.00916.77
7.2.230.0090.01116.75
7.2.220.0070.01016.62
7.2.210.0140.00716.67
7.2.200.0100.00616.54
7.2.190.0120.00816.64
7.2.180.0130.00816.46
7.2.170.0070.01116.63
7.2.160.0130.00616.56
7.2.150.0080.01317.57
7.2.140.0090.01217.64
7.2.130.0100.00817.53
7.2.120.0130.00517.47
7.2.110.0100.00717.59
7.2.100.0110.00717.53
7.2.90.0080.00917.55
7.2.80.0100.00917.47
7.2.70.0110.00717.53
7.2.60.0090.00717.38
7.2.50.0050.01217.47
7.2.40.0090.00917.47
7.2.30.0100.00817.66
7.2.20.0110.00817.42
7.2.10.0070.01117.51
7.2.00.0110.00518.15
7.1.330.0100.00916.55
7.1.320.0130.00316.53
7.1.310.0070.01416.61
7.1.300.0120.00916.48
7.1.290.0120.00916.53
7.1.280.0150.00616.63
7.1.270.0050.01216.48
7.1.260.0050.01216.54
7.1.250.0030.01416.43
7.1.240.0140.00316.36
7.1.230.0070.01316.49
7.1.220.0100.01016.46
7.1.210.0100.00916.53
7.1.200.0080.00916.26
7.1.190.0250.00916.44
7.1.180.0100.00816.48
7.1.170.0110.00816.47
7.1.160.0070.00916.37
7.1.150.0130.00516.45
7.1.140.0110.00916.44
7.1.130.0130.00716.44
7.1.120.0070.01216.51
7.1.110.0120.00916.48
7.1.100.0080.00916.91
7.1.90.0140.00816.59
7.1.80.0170.00316.48
7.1.70.0110.00616.78
7.1.60.0090.01117.54
7.1.50.0120.01016.54
7.1.40.0090.01216.40
7.1.30.0110.00816.60
7.1.20.0120.01016.61
7.1.10.0140.00516.47
7.1.00.0070.03218.35
7.0.330.0090.00816.25
7.0.320.0100.01116.18
7.0.310.0060.01116.14
7.0.300.0070.01216.14
7.0.290.0070.01416.14
7.0.280.0100.01116.13
7.0.270.0140.00516.14
7.0.260.0110.01216.19
7.0.250.0140.00816.20
7.0.240.0150.00416.27
7.0.230.0150.00516.25
7.0.220.0120.00816.32
7.0.210.0140.00816.21
7.0.200.0070.01116.36
7.0.190.0130.00516.22
7.0.180.0080.01116.20
7.0.170.0120.00916.18
7.0.160.0120.00916.26
7.0.150.0090.00916.23
7.0.140.0060.03118.20
7.0.130.0130.00716.20
7.0.120.0120.00316.13
7.0.110.0090.00716.12
7.0.100.0100.00816.08
7.0.90.0040.01516.20
7.0.80.0050.01416.15
7.0.70.0110.00616.20
7.0.60.0080.03317.52
7.0.50.0030.03616.65
7.0.40.0070.01716.82
7.0.30.0180.01716.83
7.0.20.0100.02116.81
7.0.10.0200.02816.82
7.0.00.0070.02916.83
5.6.400.0090.01315.96
5.6.390.0090.00815.90
5.6.380.0140.00415.95
5.6.370.0090.01015.98
5.6.360.0090.01116.16
5.6.350.0130.00816.06
5.6.340.0110.01116.02
5.6.330.0180.00515.97
5.6.320.0070.01215.84
5.6.310.0150.01016.13
5.6.300.0100.01416.01
5.6.290.0150.00916.01
5.6.280.0070.03117.59
5.6.270.0100.00916.04
5.6.260.0070.01415.85
5.6.250.0060.01016.01
5.6.240.0130.00916.05
5.6.230.0080.00816.11
5.6.220.0050.01416.05
5.6.210.0070.02717.64
5.6.200.0080.03116.74
5.6.190.0050.02817.53
5.6.180.0040.03717.53
5.6.170.0120.02017.57
5.6.160.0070.03317.54
5.6.150.0090.02216.73
5.6.140.0080.02216.76
5.6.130.0070.03316.83
5.6.120.0050.02017.72
5.6.110.0070.03317.63
5.6.100.0080.02117.74
5.6.90.0080.03517.75
5.6.80.0080.03317.37
5.6.70.0130.03317.51
5.6.60.0070.01115.96
5.6.50.0110.00516.00
5.6.40.0110.00615.95
5.6.30.0050.01115.94
5.6.20.0080.01016.03
5.6.10.0090.01015.79
5.6.00.0140.00615.88
5.5.380.0100.01316.27
5.5.370.0110.01116.02
5.5.360.0070.01216.01
5.5.350.0090.03117.34
5.5.340.0070.03216.81
5.5.330.0070.02217.51
5.5.320.0130.02217.27
5.5.310.0180.03217.29
5.5.300.0080.02716.71
5.5.290.0100.02116.63
5.5.280.0090.02217.78
5.5.270.0100.03317.66
5.5.260.0130.03117.59
5.5.250.0070.03617.62
5.5.240.0100.02617.37
5.5.230.0080.01315.94
5.5.220.0130.00915.94
5.5.210.0090.01115.92
5.5.200.0100.01116.06
5.5.190.0050.01715.89
5.5.180.0030.02015.90
5.5.170.0140.00815.84
5.5.160.0100.01115.94
5.5.150.0100.01315.88
5.5.140.0080.01315.80
5.5.130.0080.01215.99
5.5.120.0120.01015.77
5.5.110.0050.01615.89
5.5.100.0110.00815.93
5.5.90.0110.00716.01
5.5.80.0100.01015.99
5.5.70.0110.00615.88
5.5.60.0070.01415.88
5.5.50.0120.01015.89
5.5.40.0050.01415.90
5.5.30.0150.00616.04
5.5.20.0100.01015.83
5.5.10.0030.01715.84
5.5.00.0100.01015.87
5.4.450.0210.02815.00
5.4.440.0250.02414.96
5.4.430.0190.02014.94
5.4.420.0220.02514.96
5.4.410.0270.02815.00
5.4.400.0330.00714.76
5.4.390.0280.00514.73
5.4.380.0160.02214.71
5.4.370.0200.01914.71
5.4.360.0220.02014.68
5.4.350.0140.02414.61
5.4.340.0140.02414.75
5.4.330.0090.00912.65
5.4.320.0080.02012.51
5.4.310.0060.02112.59
5.4.300.0090.01712.57
5.4.290.0110.01412.60
5.4.280.0060.01812.57
5.4.270.0040.02112.49
5.4.260.0090.02214.78
5.4.250.0080.02514.76
5.4.240.0050.02714.65
5.4.230.0050.02714.83
5.4.220.0090.02314.76
5.4.210.0070.02614.81
5.4.200.0100.02214.63
5.4.190.0100.02014.75
5.4.180.0120.01914.88
5.4.170.0080.02414.90
5.4.160.0120.02614.74
5.4.150.0120.02114.76
5.4.140.0110.02213.90
5.4.130.0130.02613.95
5.4.120.0120.02313.84
5.4.110.0110.02013.94
5.4.100.0120.01813.85
5.4.90.0070.02313.90
5.4.80.0080.02314.01
5.4.70.0080.02213.98
5.4.60.0090.02913.98
5.4.50.0060.03213.87
5.4.40.0090.01913.97
5.4.30.0080.02913.99
5.4.20.0100.02213.78
5.4.10.0070.02513.88
5.4.00.0110.02513.76
5.3.290.0090.02313.11
5.3.280.0040.02513.63
5.3.270.0060.02513.61
5.3.260.0130.02113.73
5.3.250.0090.02313.60
5.3.240.0090.03113.44
5.3.230.0080.03113.56
5.3.220.0110.02613.51
5.3.210.0100.02513.50
5.3.200.0080.02613.52
5.3.190.0070.02313.56
5.3.180.0080.02213.66
5.3.170.0110.02913.60
5.3.160.0070.02413.65
5.3.150.0120.02313.64
5.3.140.0120.02013.49
5.3.130.0100.02413.56
5.3.120.0100.02313.61
5.3.110.0070.02413.57
5.3.100.0050.02613.26
5.3.90.0090.02113.24
5.3.80.0080.02313.24
5.3.70.0100.02113.26
5.3.60.0090.02113.34
5.3.50.0090.02113.29
5.3.40.0150.02313.32
5.3.30.0060.02213.24
5.3.20.0030.02713.08
5.3.10.0080.02013.12
5.3.00.0100.02213.03
5.2.170.0070.02511.63
5.2.160.0110.02211.49
5.2.150.0070.02511.57
5.2.140.0080.02611.69
5.2.130.0060.02511.55
5.2.120.0140.01611.50
5.2.110.0100.02211.57
5.2.100.0110.02611.56
5.2.90.0180.02111.58
5.2.80.0080.03011.47
5.2.70.0130.02211.45
5.2.60.0140.02011.37
5.2.50.0070.02511.43
5.2.40.0120.02211.47
5.2.30.0060.02711.44
5.2.20.0080.02411.50
5.2.10.0080.02411.43
5.2.00.0100.02911.31
5.1.60.0110.01510.95
5.1.50.0070.02010.91
5.1.40.0090.01910.89
5.1.30.0100.02211.12
5.1.20.0110.01811.20
5.1.10.0090.02010.92
5.1.00.0050.02210.91
5.0.50.0080.02110.31
5.0.40.0080.02310.14
5.0.30.0060.02410.01
5.0.20.0100.01110.06
5.0.10.0040.02110.12
5.0.00.0060.02610.00
4.4.90.0050.0129.39
4.4.80.0040.0139.39
4.4.70.0080.0109.39
4.4.60.0040.0129.39
4.4.50.0090.0099.39
4.4.40.0030.0219.39
4.4.30.0020.0149.39
4.4.20.0050.0119.39
4.4.10.0030.0169.39
4.4.00.0090.0149.39
4.3.110.0030.0149.39
4.3.100.0050.0179.39
4.3.90.0020.0149.39
4.3.80.0080.0239.39
4.3.70.0050.0149.39
4.3.60.0080.0099.39
4.3.50.0030.0149.39
4.3.40.0080.0169.39
4.3.30.0090.0139.39
4.3.20.0050.0169.39
4.3.10.0000.0169.39
4.3.00.0080.01210.57

preferences:
39.47 ms | 401 KiB | 5 Q