3v4l.org

run code in 300+ PHP versions simultaneously
<?php function esc_attr( $string ) { return $string; } function sanitize_key( $key ) { return $key; } function test( $choices ) { foreach( $choices as $key => $value ) { if ( is_integer( $key ) ) { $field_name = "field[$key]"; } elseif ( is_string( $key ) ) { $field_name = sprintf( 'field[%s]', sanitize_key( $key ) ); } else { // may want to throw an error here. } printf( '<input name="%s" value="1"/>', esc_attr( $field_name ) ); echo "\n"; } } echo "An indexed array\n"; $choices = array( 'Red', 'Blue', 'Green' ); test( $choices ); echo "\n\nAssociative array\n"; $choices = array( 'red' => 'Red', 'blue' => 'Blue', 'green' => 'Green' ); test( $choices );

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.5.10.0110.00816.62
8.5.00.0110.01119.91
8.4.150.0020.00014.05
8.4.140.0110.01117.25
8.4.130.0140.00618.84
8.4.120.0110.00920.52
8.4.110.0170.00717.59
8.4.100.0190.00717.85
8.4.90.0180.00618.46
8.4.80.0170.00717.79
8.4.70.0150.00518.29
8.4.60.0200.00517.86
8.4.50.0180.00518.09
8.4.40.0170.00917.28
8.4.30.0170.00618.38
8.4.20.0160.00517.47
8.4.10.0130.01018.53
8.3.280.0120.00818.34
8.3.270.0120.00716.54
8.3.260.0110.00916.46
8.3.250.0100.00819.02
8.3.240.0120.00816.87
8.3.230.0160.00716.30
8.3.220.0170.00517.16
8.3.210.0160.00716.97
8.3.200.0170.00616.33
8.3.190.0180.00616.70
8.3.180.0170.00716.51
8.3.170.0130.00717.86
8.3.160.0190.00516.89
8.3.150.0160.00617.91
8.3.140.0170.00316.36
8.3.130.0180.00616.61
8.3.120.0170.00518.53
8.3.110.0180.00417.03
8.3.100.0150.00519.04
8.3.90.0190.00420.27
8.3.80.0150.00616.37
8.3.70.0180.00616.51
8.3.60.0170.00816.96
8.3.50.0180.00616.86
8.3.40.0180.00317.70
8.3.30.0160.00617.79
8.3.20.0150.00419.50
8.3.10.0140.00319.86
8.3.00.0160.00320.24
8.2.290.0150.00617.67
8.2.280.0150.00516.90
8.2.270.0150.00616.71
8.2.260.0140.00317.57
8.2.250.0120.00917.65
8.2.240.0120.00616.51
8.2.230.0150.00517.78
8.2.220.0140.00323.49
8.2.210.0150.00519.70
8.2.200.0160.00516.36
8.2.190.0150.00516.34
8.2.180.0150.00719.44
8.2.170.0160.00419.87
8.2.160.0160.00619.38
8.2.150.0130.00720.68
8.2.140.0150.00419.83
8.2.130.0180.00420.81
8.2.120.0150.00418.35
8.2.110.0150.00418.89
8.2.100.0150.00518.20
8.2.90.0130.00617.43
8.2.80.0150.00517.35
8.2.70.0140.00517.40
8.2.60.0150.00518.04
8.2.50.0130.00617.43
8.2.40.0120.00517.56
8.2.30.0140.00417.50
8.2.20.0110.00718.43
8.2.10.0130.00517.42
8.2.00.0140.00418.60
8.1.330.0160.00617.95
8.1.320.0160.00615.83
8.1.310.0170.00316.14
8.1.300.0120.00816.53
8.1.290.0150.00416.83
8.1.280.0150.00619.34
8.1.270.0130.00519.46
8.1.260.0140.00420.25
8.1.250.0140.00321.43
8.1.240.0120.00518.71
8.1.230.0120.00618.96
8.1.220.0160.00319.01
8.1.210.0140.00418.86
8.1.200.0120.00517.15
8.1.190.0120.00417.18
8.1.180.0150.00417.42
8.1.170.0130.00417.75
8.1.160.0110.00617.67
8.1.150.0100.00617.50
8.1.140.0140.00317.20
8.1.130.0110.00418.25
8.1.120.0100.00717.85
8.1.110.0100.00617.17
8.1.100.0120.00417.13
8.1.90.0110.00517.14
8.1.80.0120.00417.31
8.1.70.0110.00417.28
8.1.60.0120.00317.41
8.1.50.0110.00517.40
8.1.40.0180.00417.41
8.1.30.0150.00817.40
8.1.20.0180.00517.27
8.1.10.0180.00617.35
8.1.00.0210.00617.26
8.0.300.0180.00518.32
8.0.290.0180.00616.48
8.0.280.0170.00617.12
8.0.270.0180.00516.59
8.0.260.0140.00217.19
8.0.250.0130.00416.75
8.0.240.0170.00416.66
8.0.230.0130.00416.72
8.0.220.0180.00516.61
8.0.210.0160.00516.65
8.0.200.0130.00516.59
8.0.190.0190.00516.72
8.0.180.0130.00716.78
8.0.170.0170.00516.64
8.0.160.0190.00416.78
8.0.150.0160.00716.60
8.0.140.0150.00616.64
8.0.130.0240.00316.58
8.0.120.0220.00616.63
8.0.110.0220.00716.62
8.0.100.0250.00516.56
8.0.90.0210.00616.57
8.0.80.0220.00616.52
8.0.70.0170.00916.55
8.0.60.0190.00716.65
8.0.50.0200.00616.61
8.0.30.0170.00716.61
8.0.20.0210.00516.69
8.0.10.0180.00316.80
8.0.00.0250.00716.79
7.4.330.0220.00516.14
7.4.320.0200.00616.32
7.4.300.0200.00716.31
7.4.290.0210.00516.37
7.4.280.0150.00716.37
7.4.270.0210.00616.29
7.4.260.0230.00616.32
7.4.250.0240.00716.26
7.4.240.0260.00716.25
7.4.230.0240.00616.25
7.4.220.0250.00616.31
7.4.210.0250.00616.34
7.4.200.0210.00616.32
7.4.190.0210.00416.40
7.4.180.0150.00716.40
7.4.160.0200.00116.41
7.4.150.0220.00616.33
7.4.140.0280.00416.28
7.4.130.0180.00616.14
7.4.120.0200.00516.23
7.4.110.0160.00716.34
7.4.100.0170.00516.40
7.4.90.0210.00616.28
7.4.80.0180.00716.21
7.4.70.0270.00616.17
7.4.60.0260.00516.15
7.4.50.0220.00616.05
7.4.40.0200.00716.15
7.4.30.0210.00516.27
7.4.20.0260.00516.34
7.4.10.0240.00616.27
7.4.00.0230.00516.29
7.3.330.0230.00616.19
7.3.320.0190.00616.07
7.3.310.0210.00416.09
7.3.300.0230.00816.21
7.3.290.0210.00816.04
7.3.280.0240.00816.18
7.3.270.0200.00716.14
7.3.260.0210.00716.16
7.3.250.0220.00616.08
7.3.240.0230.00416.07
7.3.230.0170.00616.06
7.3.220.0240.00615.90
7.3.210.0260.00515.80
7.3.200.0220.00515.97
7.3.190.0240.00716.01
7.3.180.0260.00615.88
7.3.170.0220.00316.22
7.3.160.0270.00515.97
7.3.150.0240.00715.81
7.3.140.0200.00516.09
7.3.130.0260.00416.02

preferences:
105.18 ms | 403 KiB | 5 Q