3v4l.org

run code in 300+ PHP versions simultaneously
<?php function __( $str ) { return $str; } function _doing_it_wrong( $func, $error_message, $version ) { trigger_error( $error_message, E_USER_NOTICE ); } class WP_List_Util { /** * The input array. * * @since 4.7.0 * @var array */ private $input = array(); /** * The output array. * * @since 4.7.0 * @var array */ private $output = array(); /** * Temporary arguments for sorting. * * @since 4.7.0 * @var string[] */ private $orderby = array(); /** * Constructor. * * Sets the input array. * * @since 4.7.0 * * @param array $input Array to perform operations on. */ public function __construct( $input ) { $this->output = $input; $this->input = $input; } public function pluck( $field, $index_key = null ) { $newlist = array(); if ( ! $index_key ) { /* * This is simple. Could at some point wrap array_column() * if we knew we had an array of arrays. */ foreach ( $this->output as $key => $value ) { if ( is_object( $value ) ) { $newlist[ $key ] = $value->$field; } elseif ( is_array( $value ) ) { $newlist[ $key ] = $value[ $field ]; } else { _doing_it_wrong( __METHOD__, __( 'Values for the input array must be either objects or arrays.' ), '6.2.0' ); } } $this->output = $newlist; return $this->output; } /* * When index_key is not set for a particular item, push the value * to the end of the stack. This is how array_column() behaves. */ foreach ( $this->output as $value ) { if ( is_object( $value ) ) { if ( isset( $value->$index_key ) ) { $newlist[ $value->$index_key ] = $value->$field; } else { $newlist[] = $value->$field; } } elseif ( is_array( $value ) ) { if ( isset( $value[ $index_key ] ) ) { $newlist[ $value[ $index_key ] ] = $value[ $field ]; } else { $newlist[] = $value[ $field ]; } } else { // _doing_it_wrong( // __METHOD__, // __( 'Values for the input array must be either objects or arrays.' ), // '6.2.0' // ); } } $this->output = $newlist; return $this->output; } } function wp_list_pluck( $input_list, $field, $index_key = null ) { if ( ! is_array( $input_list ) ) { return array(); } $util = new WP_List_Util( $input_list ); return $util->pluck( $field, $index_key ); } /* * Test with an array of arrays. */ $input_list = array( array( '123' => '456' ), array( 'foo' => 'bar' ), array( 'foo' => 'baz' ), ); var_dump( array_column( $input_list, 'foo', null ) ); var_dump( wp_list_pluck( $input_list, 'foo', null ) ); /* * Test with an array of objects. */ $input_list = array( (object) array( '123' => '456' ), (object) array( 'foo' => 'bar' ), (object) array( 'foo' => 'baz' ), ); var_dump( wp_list_pluck( $input_list, 'foo', null ) );

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.0110.01118.06
8.4.130.0120.00817.72
8.4.120.0140.00620.59
8.4.110.0040.00520.40
8.4.100.0120.00917.69
8.4.90.0120.00820.73
8.4.80.0070.01020.83
8.4.70.0110.01219.07
8.4.60.0090.01120.57
8.4.50.0110.00820.22
8.4.40.0140.00717.86
8.4.30.0180.00318.72
8.4.20.0070.01317.71
8.4.10.0040.01219.48
8.3.260.0110.00916.91
8.3.250.0140.00618.98
8.3.240.0130.00616.79
8.3.230.0140.00716.75
8.3.220.0110.00818.84
8.3.210.0110.00616.88
8.3.200.0050.00516.51
8.3.190.0060.00317.19
8.3.180.0070.00918.84
8.3.170.0130.00617.34
8.3.160.0150.00316.92
8.3.150.0100.01017.22
8.3.140.0050.00316.94
8.3.130.0080.00018.61
8.3.120.0060.00319.05
8.3.110.0090.00920.94
8.3.100.0150.00024.06
8.3.90.0040.00426.77
8.3.80.0030.00617.97
8.3.70.0120.00318.41
8.3.60.0120.00316.90
8.3.50.0200.00318.67
8.3.40.0140.00021.79
8.3.30.0310.01322.96
8.3.20.0150.00723.31
8.3.10.0110.01123.30
8.3.00.0200.00822.96
8.2.290.0100.00817.07
8.2.280.0070.01318.68
8.2.270.0090.00916.78
8.2.260.0110.00716.88
8.2.250.0050.00316.75
8.2.240.0120.00317.11
8.2.230.0100.00022.58
8.2.220.0030.00637.54
8.2.210.0090.00026.77
8.2.200.0070.00317.00
8.2.190.0070.01016.75
8.2.180.0100.00716.63
8.2.170.0030.01022.96
8.2.160.0310.00322.96
8.2.150.0190.00622.96
8.2.140.0070.01322.96
8.2.130.0100.00822.96
8.2.120.0120.00822.96
8.2.110.0090.00822.96
8.2.100.0210.00722.96
8.2.90.0240.00822.96
8.2.80.0130.00922.96
8.2.70.0210.00722.96
8.2.60.0110.00722.96
8.2.50.0160.00922.96
8.2.40.0180.01122.96
8.2.30.0180.00522.96
8.2.20.0210.01022.96
8.2.10.0110.00922.96
8.2.00.0180.00922.96
8.1.330.0110.00721.66
8.1.320.0090.01116.07
8.1.310.0120.00616.66
8.1.300.0080.00018.38
8.1.290.0030.00630.84
8.1.280.0120.00325.92
8.1.270.0060.01322.96
8.1.260.0200.00422.96
8.1.250.0100.00823.96
8.1.240.0230.00322.96
8.1.230.0190.00622.96
8.1.220.0110.00922.96
8.1.210.0220.00522.96
8.1.200.0140.00822.96
8.1.190.0180.00622.96
8.1.180.0170.01022.96
8.1.170.0180.00622.96
8.1.160.0120.01022.96
8.1.150.0150.00822.96
8.1.140.0240.00822.96
8.1.130.0170.00822.96
8.1.120.0240.00622.96
8.1.110.0190.00822.96
8.1.100.0140.01022.96
8.1.90.0200.00722.96
8.1.80.0230.00322.96
8.1.70.0180.00322.96
8.1.60.0290.00722.96
8.1.50.0230.00622.96
8.1.40.0230.00522.96
8.1.30.0090.00922.96
8.1.20.0190.00722.96
8.1.10.0230.00822.96
8.1.00.0260.00922.96
8.0.300.0110.00622.96
8.0.290.0200.00922.96
8.0.280.0280.00322.96
8.0.270.0060.01122.96
8.0.260.0230.00522.96
8.0.250.0140.01122.96
8.0.240.0190.00922.96
8.0.230.0160.00722.96
8.0.220.0180.00222.96
8.0.210.0270.00022.96
8.0.200.0220.00622.96
8.0.190.0240.00422.96
8.0.180.0160.00622.96
8.0.170.0240.00522.96
8.0.160.0080.00822.96
8.0.150.0250.00322.96
8.0.140.0180.01122.96
8.0.130.0160.00922.96
8.0.120.0220.00622.96
8.0.110.0210.00722.96
8.0.100.0190.00722.96
8.0.90.0280.00022.96
8.0.80.0220.00422.96
8.0.70.0160.00322.96
8.0.60.0200.01322.96
8.0.50.0160.01122.96
8.0.30.0090.01022.96
8.0.20.0080.00822.96
8.0.10.0210.00922.96
8.0.00.0240.00422.96
7.4.330.0210.01022.96
7.4.320.0290.00922.96
7.4.300.0330.00422.96
7.4.290.0310.00222.96
7.4.280.0250.00522.96
7.4.270.0240.00622.96
7.4.260.0200.01122.96
7.4.250.0310.00522.96
7.4.240.0300.00522.96
7.4.230.0270.00922.96
7.4.220.0300.00622.96
7.4.210.0320.00222.96
7.4.200.0260.00922.96
7.4.190.0290.00622.96
7.4.180.0240.00722.96
7.4.160.0300.00522.96
7.4.150.0270.00522.96
7.4.140.0290.00322.96
7.4.130.0240.00922.96
7.4.120.0260.00622.96
7.4.110.0260.00722.96
7.4.100.0320.00122.96
7.4.90.0220.00822.96
7.4.80.0250.00522.96
7.4.70.0250.00422.96
7.4.60.0260.00522.96
7.4.50.0320.00222.96
7.4.40.0230.01322.96
7.4.30.0320.00322.96
7.4.20.0240.00822.96
7.4.10.0200.01422.96
7.4.00.0250.00722.96
7.3.330.0210.00922.96
7.3.320.0260.00522.96
7.3.310.0310.00722.96
7.3.300.0290.00322.96
7.3.290.0230.00622.96
7.3.280.0210.00822.96
7.3.270.0250.00422.96
7.3.260.0240.00922.96
7.3.250.0280.00322.96
7.3.240.0270.00622.96
7.3.230.0260.00722.96
7.3.220.0290.00322.96
7.3.210.0270.00922.96
7.3.200.0250.00822.96
7.3.190.0200.01522.96
7.3.180.0310.00522.96
7.3.170.0240.00722.96
7.3.160.0270.00722.96
7.3.150.0260.00722.96
7.3.140.0270.00522.96
7.3.130.0250.00822.96
7.3.120.0230.00722.96
7.3.110.0210.00722.96
7.3.100.0270.00122.96
7.3.90.0220.00722.96
7.3.80.0230.00522.96
7.3.70.0150.00822.96
7.3.60.0210.00822.96
7.3.50.0220.00622.96
7.3.40.0290.00022.96
7.3.30.0240.00922.96
7.3.20.0280.00822.96
7.3.10.0290.00522.96
7.3.00.0250.00522.96
7.2.340.0240.01122.96
7.2.330.0310.00722.96
7.2.320.0230.01122.96
7.2.310.0270.00722.96
7.2.300.0290.00522.96
7.2.290.0180.01522.96
7.2.280.0210.00622.96
7.2.270.0260.00522.96
7.2.260.0290.00422.96
7.2.250.0200.00922.96
7.2.240.0240.00322.96
7.2.230.0280.00422.96
7.2.220.0280.00522.96
7.2.210.0270.00722.96
7.2.200.0280.00622.96
7.2.190.0250.00722.96
7.2.180.0270.01222.96
7.2.170.0300.00722.96
7.2.160.0280.00722.96
7.2.150.0240.00622.96
7.2.140.0270.01322.96
7.2.130.0270.00622.96
7.2.120.0310.00722.96
7.2.110.0270.01022.96
7.2.100.0090.01122.96
7.2.90.0300.00522.96
7.2.80.0190.01322.96
7.2.70.0250.00322.96
7.2.60.0240.00422.96
7.2.50.0210.00722.96
7.2.40.0250.00622.96
7.2.30.0190.00922.96
7.2.20.0210.00822.96
7.2.10.0200.00922.96
7.2.00.0090.00822.96
7.1.330.0190.00822.96
7.1.320.0200.00622.96
7.1.310.0150.01122.96
7.1.300.0180.00522.96
7.1.290.0210.00422.96
7.1.280.0250.00422.96
7.1.270.0230.00422.96
7.1.260.0220.00622.96
7.1.250.0240.00522.96
7.1.240.0250.00422.96
7.1.230.0180.01022.96
7.1.220.0230.00522.96
7.1.210.0200.00822.96
7.1.200.0220.00622.96
7.1.190.0220.00822.96
7.1.180.0210.00522.96
7.1.170.0170.00822.96
7.1.160.0240.00722.96
7.1.150.0240.00422.96
7.1.140.0230.00722.96
7.1.130.0180.00922.96
7.1.120.0220.00622.96
7.1.110.0190.00622.96
7.1.100.0230.00422.96
7.1.90.0180.01122.96
7.1.80.0180.00922.96
7.1.70.0190.01022.96
7.1.60.0220.00522.96
7.1.50.0170.00822.96
7.1.40.0220.00322.96
7.1.30.0220.00722.96
7.1.20.0240.00522.96
7.1.10.0200.01022.96
7.1.00.0120.00522.96
7.0.330.0190.00922.96
7.0.320.0220.00422.96
7.0.310.0220.00422.96
7.0.300.0220.00422.96
7.0.290.0170.00822.96
7.0.280.0240.00522.96
7.0.270.0180.01222.96
7.0.260.0210.00522.96
7.0.250.0250.00722.96
7.0.240.0210.00922.96
7.0.230.0230.00522.96
7.0.220.0240.00222.96
7.0.210.0200.00622.96
7.0.200.0220.00922.96
7.0.190.0270.00822.96
7.0.180.0220.00522.96
7.0.170.0240.00522.96
7.0.160.0190.00822.96
7.0.150.0220.00522.96
7.0.140.0190.00622.96
7.0.130.0230.00422.96
7.0.120.0160.00822.96
7.0.110.0230.00722.96
7.0.100.0140.00622.96
7.0.90.0220.00822.96
7.0.80.0200.00222.96
7.0.70.0170.00922.96
7.0.60.0080.01122.96
7.0.50.0140.00922.96
7.0.40.0140.00822.96
7.0.30.0130.00622.96
7.0.20.0250.00322.96
7.0.10.0210.01022.96
7.0.00.0200.00622.96
5.6.400.0170.00822.96
5.6.390.0220.00222.96
5.6.380.0140.01122.96
5.6.370.0220.00922.96
5.6.360.0240.00422.96
5.6.350.0190.00722.96
5.6.340.0250.00222.96
5.6.330.0170.00822.96
5.6.320.0180.00822.96
5.6.310.0220.01022.96
5.6.300.0240.00422.96
5.6.290.0220.00622.96
5.6.280.0250.00622.96
5.6.270.0220.01022.96
5.6.260.0250.00422.96
5.6.250.0280.00222.96
5.6.240.0230.00222.96
5.6.230.0240.00522.96
5.6.220.0190.00922.96
5.6.210.0200.00522.96
5.6.200.0180.00722.96
5.6.190.0120.01422.96
5.6.180.0170.00922.96
5.6.170.0220.00522.96
5.6.160.0190.00722.96
5.6.150.0170.00922.96
5.6.140.0200.00722.96
5.6.130.0210.00822.96
5.6.120.0200.01022.96
5.6.110.0250.00522.96
5.6.100.0230.00522.96
5.6.90.0170.01122.96
5.6.80.0140.01422.96
5.6.70.0150.01022.96
5.6.60.0200.00622.96
5.6.50.0180.00622.96
5.6.40.0180.00822.96
5.6.30.0180.00622.96
5.6.20.0190.00622.96
5.6.10.0210.00322.96
5.6.00.0200.00622.96
5.5.380.0220.00622.96
5.5.370.0210.00722.96
5.5.360.0180.00922.96
5.5.350.0220.00522.96
5.5.340.0200.00722.96
5.5.330.0210.00622.96
5.5.320.0190.01022.96
5.5.310.0230.00722.96
5.5.300.0280.00322.96
5.5.290.0230.00722.96
5.5.280.0170.01322.96
5.5.270.0200.00722.96
5.5.260.0230.00322.96
5.5.250.0260.00522.96
5.5.240.0260.00322.96
5.5.230.0210.00622.96
5.5.220.0170.00822.96
5.5.210.0240.00422.96
5.5.200.0260.00222.96
5.5.190.0190.00922.96
5.5.180.0200.00722.96
5.5.170.0210.00622.96
5.5.160.0220.00522.96
5.5.150.0150.01222.96
5.5.140.0200.00722.96
5.5.130.0200.00822.96
5.5.120.0170.01022.96
5.5.110.0240.00222.96
5.5.100.0200.00622.96
5.5.90.0190.00622.96
5.5.80.0210.00622.96
5.5.70.0250.00522.96
5.5.60.0220.00622.96
5.5.50.0240.00522.96
5.5.40.0180.01022.96
5.5.30.0240.00322.96
5.5.20.0240.00322.96
5.5.10.0220.00522.96
5.5.00.0200.00522.96
5.4.450.0160.00622.96
5.4.440.0180.00722.96
5.4.430.0210.00222.96
5.4.420.0200.00522.96
5.4.410.0200.00522.96
5.4.400.0200.00322.96
5.4.390.0190.00322.96
5.4.380.0200.00522.96
5.4.370.0220.00222.96
5.4.360.0200.00322.96
5.4.350.0210.00322.96
5.4.340.0180.00722.96
5.4.330.0190.00522.96
5.4.320.0200.00422.96
5.4.310.0180.00522.96
5.4.300.0180.00522.96
5.4.290.0210.00322.96
5.4.280.0170.00522.96
5.4.270.0210.00522.96
5.4.260.0220.00522.96
5.4.250.0240.00522.96
5.4.240.0210.00822.96
5.4.230.0220.00422.96
5.4.220.0190.00322.96
5.4.210.0200.00522.96
5.4.200.0200.00622.96
5.4.190.0220.00522.96
5.4.180.0210.00322.96
5.4.170.0230.00222.96
5.4.160.0210.00322.96
5.4.150.0210.00522.96
5.4.140.0220.00522.96
5.4.130.0180.01022.96
5.4.120.0260.00222.96
5.4.110.0190.00322.96
5.4.100.0160.00422.96
5.4.90.0210.00222.96
5.4.80.0190.00322.96
5.4.70.0140.00422.96
5.4.60.0110.00022.96
5.4.50.0100.00022.96
5.4.40.0090.00122.96
5.4.30.0090.00222.96
5.4.20.0070.00322.96
5.4.10.0100.00422.96
5.4.00.0030.00822.96
5.3.290.0090.00222.96
5.3.280.0090.00222.96
5.3.270.0080.00322.96
5.3.260.0080.00322.96
5.3.250.0080.00322.96
5.3.240.0030.00822.96
5.3.230.0060.00522.96
5.3.220.0100.00222.96
5.3.210.0040.00622.96
5.3.200.0050.00522.96
5.3.190.0050.00622.96
5.3.180.0060.00622.96
5.3.170.0030.00922.96
5.3.160.0070.00522.96
5.3.150.0060.00522.96
5.3.140.0080.00422.96
5.3.130.0050.00622.96
5.3.120.0080.00322.96
5.3.110.0080.00322.96
5.3.100.0120.00222.96
5.3.90.0090.00322.96
5.3.80.0110.00122.96
5.3.70.0070.00422.96
5.3.60.0040.00722.96
5.3.50.0080.00322.96
5.3.40.0050.00522.96
5.3.30.0030.01022.96
5.3.20.0030.00922.96
5.3.10.0070.00322.96
5.3.00.0050.00822.96
5.2.170.0040.00622.96
5.2.160.0040.00722.96
5.2.150.0050.00622.96
5.2.140.0060.00322.96
5.2.130.0030.00622.96
5.2.120.0050.00522.96
5.2.110.0060.00422.96
5.2.100.0030.00722.96
5.2.90.0060.00522.96
5.2.80.0020.00822.96
5.2.70.0100.00022.96
5.2.60.0090.00222.96
5.2.50.0090.00222.96
5.2.40.0080.00222.96
5.2.30.0130.00322.96
5.2.20.0150.00222.96
5.2.10.0140.00322.96
5.2.00.0120.00422.96
5.1.60.0100.00522.96
5.1.50.0150.00022.96
5.1.40.0090.00622.96
5.1.30.0130.00322.96
5.1.20.0120.00322.96
5.1.10.0120.00422.96
5.1.00.0110.00222.96
5.0.50.0080.00422.96
5.0.40.0120.00022.96
5.0.30.0110.00222.96
5.0.20.0090.00322.96
5.0.10.0100.00122.96
5.0.00.0080.00422.96
4.4.90.0020.00522.96
4.4.80.0050.00222.96
4.4.70.0070.00022.96
4.4.60.0070.00022.96
4.4.50.0030.00322.96
4.4.40.0060.00122.96
4.4.30.0070.00022.96
4.4.20.0050.00222.96
4.4.10.0080.00022.96
4.4.00.0080.00022.96
4.3.110.0070.00022.96
4.3.100.0050.00322.96
4.3.90.0060.00122.96
4.3.80.0060.00122.96
4.3.70.0070.00022.96
4.3.60.0070.00022.96
4.3.50.0060.00122.96
4.3.40.0000.00722.96
4.3.30.0050.00122.96
4.3.20.0060.00022.96
4.3.10.0030.00322.96
4.3.00.0040.00122.96

preferences:
40.52 ms | 403 KiB | 5 Q