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 ) ) { if ( property_exists( $value, $field ) ) { $newlist[ $key ] = $value->$field; } } elseif ( is_array( $value ) ) { if ( array_key_exists( $field, $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 ( property_exists( $value, $field ) ) { if ( property_exists( $value, $index_key ) ) { $newlist[ $value->$index_key ] = $value->$field; } else { $newlist[] = $value->$field; } } } elseif ( is_array( $value ) ) { if ( array_key_exists( $field, $value ) ) { if ( array_key_exists( $index_key, $value ) ) { $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.20.0100.01018.05
8.4.10.0160.00019.48
8.3.150.0090.00917.22
8.3.140.0030.00520.52
8.3.130.0000.00918.49
8.3.120.0080.00019.21
8.3.110.0000.00920.94
8.3.100.0070.00424.06
8.3.90.0060.00326.77
8.3.80.0080.00417.97
8.3.70.0200.00316.75
8.3.60.0120.00316.51
8.3.50.0140.00416.78
8.3.40.0110.00421.86
8.3.30.0240.00922.96
8.3.20.0130.00623.33
8.3.10.0100.00823.31
8.3.00.0190.00622.96
8.2.270.0110.00716.56
8.2.260.0160.00317.30
8.2.250.0150.00316.85
8.2.240.0140.00517.07
8.2.230.0060.00322.58
8.2.220.0130.00637.54
8.2.210.0080.00026.77
8.2.200.0000.00918.31
8.2.190.0040.01118.40
8.2.180.0070.00716.63
8.2.170.0140.00022.96
8.2.160.0270.00622.96
8.2.150.0230.00822.96
8.2.140.0090.01022.96
8.2.130.0090.00922.96
8.2.120.0160.00422.96
8.2.110.0100.00522.96
8.2.100.0140.00922.96
8.2.90.0280.00722.96
8.2.80.0080.01322.96
8.2.70.0200.01022.96
8.2.60.0110.01022.96
8.2.50.0180.00522.96
8.2.40.0170.00622.96
8.2.30.0210.00522.96
8.2.20.0130.01122.96
8.2.10.0130.00622.96
8.2.00.0200.00822.96
8.1.310.0070.00716.81
8.1.300.0000.01019.54
8.1.290.0060.00330.84
8.1.280.0090.00925.92
8.1.270.0130.00522.96
8.1.260.0110.00823.33
8.1.250.0100.00722.96
8.1.240.0220.00522.96
8.1.230.0200.00722.96
8.1.220.0100.01022.96
8.1.210.0220.00322.96
8.1.200.0160.00422.96
8.1.190.0190.00322.96
8.1.180.0220.00422.96
8.1.170.0120.00822.96
8.1.160.0130.01022.96
8.1.150.0190.00722.96
8.1.140.0210.00522.96
8.1.130.0200.00422.96
8.1.120.0200.00922.96
8.1.110.0180.01022.96
8.1.100.0140.00722.96
8.1.90.0180.00822.96
8.1.80.0170.00522.96
8.1.70.0150.00722.96
8.1.60.0260.00322.96
8.1.50.0210.00722.96
8.1.40.0160.01122.96
8.1.30.0080.01122.96
8.1.20.0260.00722.96
8.1.10.0250.00622.96
8.1.00.0240.00322.96
8.0.300.0110.00522.96
8.0.290.0210.00722.96
8.0.280.0240.00822.96
8.0.270.0110.00722.96
8.0.260.0190.00622.96
8.0.250.0240.00322.96
8.0.240.0190.00622.96
8.0.230.0180.00522.96
8.0.220.0100.01022.96
8.0.210.0280.00722.96
8.0.200.0310.00222.96
8.0.190.0260.00522.96
8.0.180.0160.00822.96
8.0.170.0250.00522.96
8.0.160.0140.00422.96
8.0.150.0210.01122.96
8.0.140.0280.00522.96
8.0.130.0220.00822.96
8.0.120.0220.00822.96
8.0.110.0260.01122.96
8.0.100.0200.00822.96
8.0.90.0170.01322.96
8.0.80.0180.01122.96
8.0.70.0050.01022.96
8.0.60.0250.00522.96
8.0.50.0190.00722.96
8.0.30.0100.00422.96
8.0.20.0120.00322.96
8.0.10.0180.00822.96
8.0.00.0190.00722.96
7.4.330.0210.00322.96
7.4.320.0240.00622.96
7.4.300.0250.00822.96
7.4.290.0260.00922.96
7.4.280.0310.00522.96
7.4.270.0270.00822.96
7.4.260.0270.00922.96
7.4.250.0290.00622.96
7.4.240.0260.00822.96
7.4.230.0310.00322.96
7.4.220.0300.00622.96
7.4.210.0300.00822.96
7.4.200.0330.00622.96
7.4.190.0230.01222.96
7.4.180.0230.00622.96
7.4.160.0300.00622.96
7.4.150.0280.00722.96
7.4.140.0260.00522.96
7.4.130.0240.00422.96
7.4.120.0250.00522.96
7.4.110.0230.00722.96
7.4.100.0330.00222.96
7.4.90.0280.00422.96
7.4.80.0240.00422.96
7.4.70.0220.00622.96
7.4.60.0240.00322.96
7.4.50.0270.00622.96
7.4.40.0250.00722.96
7.4.30.0240.00922.96
7.4.20.0240.00822.96
7.4.10.0240.00722.96
7.4.00.0310.00122.96
7.3.330.0340.00722.96
7.3.320.0280.00422.96
7.3.310.0310.00422.96
7.3.300.0260.00522.96
7.3.290.0230.00622.96
7.3.280.0220.00622.96
7.3.270.0200.00722.96
7.3.260.0230.00522.96
7.3.250.0230.00522.96
7.3.240.0300.00422.96
7.3.230.0270.00522.96
7.3.220.0250.00822.96
7.3.210.0270.00522.96
7.3.200.0320.00522.96
7.3.190.0310.00622.96
7.3.180.0270.00622.96
7.3.170.0200.00722.96
7.3.160.0250.00922.96
7.3.150.0270.00522.96
7.3.140.0300.00222.96
7.3.130.0300.00622.96
7.3.120.0260.00822.96
7.3.110.0280.00722.96
7.3.100.0280.01122.96
7.3.90.0290.00622.96
7.3.80.0270.00522.96
7.3.70.0170.00722.96
7.3.60.0200.01122.96
7.3.50.0270.00322.96
7.3.40.0260.00322.96
7.3.30.0230.00622.96
7.3.20.0240.00622.96
7.3.10.0220.00622.96
7.3.00.0190.01122.96
7.2.340.0210.00922.96
7.2.330.0210.00622.96
7.2.320.0230.00522.96
7.2.310.0240.00722.96
7.2.300.0240.00522.96
7.2.290.0230.00922.96
7.2.280.0230.00522.96
7.2.270.0230.00622.96
7.2.260.0240.00922.96
7.2.250.0280.00322.96
7.2.240.0270.00922.96
7.2.230.0260.00922.96
7.2.220.0240.00722.96
7.2.210.0220.00922.96
7.2.200.0260.00822.96
7.2.190.0290.00522.96
7.2.180.0220.00822.96
7.2.170.0260.00822.96
7.2.160.0260.00522.96
7.2.150.0210.01522.96
7.2.140.0230.00822.96
7.2.130.0250.00722.96
7.2.120.0250.00622.96
7.2.110.0200.00822.96
7.2.100.0050.01322.96
7.2.90.0250.00922.96
7.2.80.0250.00822.96
7.2.70.0290.00822.96
7.2.60.0280.00522.96
7.2.50.0250.00622.96
7.2.40.0320.00622.96
7.2.30.0300.00522.96
7.2.20.0170.01322.96
7.2.10.0190.01322.96
7.2.00.0130.00822.96
7.1.330.0290.00322.96
7.1.320.0270.00422.96
7.1.310.0220.00822.96
7.1.300.0240.00622.96
7.1.290.0210.00522.96
7.1.280.0180.00722.96
7.1.270.0180.00522.96
7.1.260.0210.00422.96
7.1.250.0210.00422.96
7.1.240.0190.00622.96
7.1.230.0180.00822.96
7.1.220.0190.00622.96
7.1.210.0270.00322.96
7.1.200.0240.00622.96
7.1.190.0220.00822.96
7.1.180.0270.00622.96
7.1.170.0280.00522.96
7.1.160.0230.00922.96
7.1.150.0200.00822.96
7.1.140.0220.00722.96
7.1.130.0280.00622.96
7.1.120.0280.00422.96
7.1.110.0240.00922.96
7.1.100.0250.00922.96
7.1.90.0250.00522.96
7.1.80.0280.00222.96
7.1.70.0270.00822.96
7.1.60.0250.00222.96
7.1.50.0220.00522.96
7.1.40.0220.00322.96
7.1.30.0240.00222.96
7.1.20.0230.00722.96
7.1.10.0260.00322.96
7.1.00.0100.00622.96
7.0.330.0220.00522.96
7.0.320.0230.00322.96
7.0.310.0220.00722.96
7.0.300.0240.00422.96
7.0.290.0230.00622.96
7.0.280.0250.00422.96
7.0.270.0220.00622.96
7.0.260.0190.01322.96
7.0.250.0210.01122.96
7.0.240.0250.00822.96
7.0.230.0270.00622.96
7.0.220.0220.00722.96
7.0.210.0240.00822.96
7.0.200.0230.00522.96
7.0.190.0190.00622.96
7.0.180.0250.00622.96
7.0.170.0210.01122.96
7.0.160.0170.01022.96
7.0.150.0210.00422.96
7.0.140.0190.00722.96
7.0.130.0240.00522.96
7.0.120.0210.00722.96
7.0.110.0190.00522.96
7.0.100.0130.00722.96
7.0.90.0190.00622.96
7.0.80.0210.00522.96
7.0.70.0220.00422.96
7.0.60.0110.00522.96
7.0.50.0160.00522.96
7.0.40.0200.00322.96
7.0.30.0070.00722.96
7.0.20.0190.00822.96
7.0.10.0180.00822.96
7.0.00.0200.00322.96
5.6.400.0170.00722.96
5.6.390.0110.01422.96
5.6.380.0210.00422.96
5.6.370.0150.01022.96
5.6.360.0170.00722.96
5.6.350.0180.00722.96
5.6.340.0210.00422.96
5.6.330.0210.00522.96
5.6.320.0190.00722.96
5.6.310.0220.00622.96
5.6.300.0230.00422.96
5.6.290.0210.00922.96
5.6.280.0230.00522.96
5.6.270.0260.00222.96
5.6.260.0240.00422.96
5.6.250.0190.00722.96
5.6.240.0180.00922.96
5.6.230.0230.00322.96
5.6.220.0210.00522.96
5.6.210.0290.00222.96
5.6.200.0240.00822.96
5.6.190.0210.00822.96
5.6.180.0210.00722.96
5.6.170.0200.00822.96
5.6.160.0200.01222.96
5.6.150.0200.01022.96
5.6.140.0150.00922.96
5.6.130.0190.00722.96
5.6.120.0200.00522.96
5.6.110.0160.01322.96
5.6.100.0250.00522.96
5.6.90.0170.01322.96
5.6.80.0250.00522.96
5.6.70.0190.01022.96
5.6.60.0190.00622.96
5.6.50.0200.00922.96
5.6.40.0250.00722.96
5.6.30.0220.00422.96
5.6.20.0220.00422.96
5.6.10.0190.00522.96
5.6.00.0240.00822.96
5.5.380.0240.00522.96
5.5.370.0230.00622.96
5.5.360.0220.00322.96
5.5.350.0230.00222.96
5.5.340.0250.00322.96
5.5.330.0230.00322.96
5.5.320.0280.00322.96
5.5.310.0250.00322.96
5.5.300.0200.00722.96
5.5.290.0170.00822.96
5.5.280.0210.00422.96
5.5.270.0230.00222.96
5.5.260.0220.00322.96
5.5.250.0170.00722.96
5.5.240.0260.00522.96
5.5.230.0240.01022.96
5.5.220.0130.01122.96
5.5.210.0230.00522.96
5.5.200.0240.00222.96
5.5.190.0170.01122.96
5.5.180.0250.00122.96
5.5.170.0230.00622.96
5.5.160.0260.00322.96
5.5.150.0150.01122.96
5.5.140.0200.00522.96
5.5.130.0230.00922.96
5.5.120.0220.00522.96
5.5.110.0220.00522.96
5.5.100.0130.01122.96
5.5.90.0190.00822.96
5.5.80.0210.00322.96
5.5.70.0180.00622.96
5.5.60.0190.00522.96
5.5.50.0190.00522.96
5.5.40.0170.00622.96
5.5.30.0160.00922.96
5.5.20.0160.00822.96
5.5.10.0190.00522.96
5.5.00.0190.00522.96
5.4.450.0150.00622.96
5.4.440.0170.00322.96
5.4.430.0180.00522.96
5.4.420.0190.00722.96
5.4.410.0260.00022.96
5.4.400.0170.00722.96
5.4.390.0190.00322.96
5.4.380.0190.00622.96
5.4.370.0170.00322.96
5.4.360.0190.00322.96
5.4.350.0170.00522.96
5.4.340.0150.00622.96
5.4.330.0160.00522.96
5.4.320.0200.00422.96
5.4.310.0160.00822.96
5.4.300.0200.00522.96
5.4.290.0230.00222.96
5.4.280.0230.00522.96
5.4.270.0200.00222.96
5.4.260.0150.00722.96
5.4.250.0220.00522.96
5.4.240.0220.00222.96
5.4.230.0150.00822.96
5.4.220.0180.00522.96
5.4.210.0200.00322.96
5.4.200.0190.00422.96
5.4.190.0150.00522.96
5.4.180.0220.00222.96
5.4.170.0210.00522.96
5.4.160.0220.00822.96
5.4.150.0260.00222.96
5.4.140.0220.00222.96
5.4.130.0150.00722.96
5.4.120.0170.00322.96
5.4.110.0210.00322.96
5.4.100.0180.00522.96
5.4.90.0170.00422.96
5.4.80.0170.00322.96
5.4.70.0180.00222.96
5.4.60.0110.00222.96
5.4.50.0060.00422.96
5.4.40.0060.00622.96
5.4.30.0090.00222.96
5.4.20.0110.00022.96
5.4.10.0120.00522.96
5.4.00.0080.00322.96
5.3.290.0050.00522.96
5.3.280.0060.00522.96
5.3.270.0060.00522.96
5.3.260.0030.00722.96
5.3.250.0090.00322.96
5.3.240.0050.00722.96
5.3.230.0070.00622.96
5.3.220.0090.00222.96
5.3.210.0070.00322.96
5.3.200.0100.00022.96
5.3.190.0100.00222.96
5.3.180.0080.00522.96
5.3.170.0060.00622.96
5.3.160.0030.01022.96
5.3.150.0070.00522.96
5.3.140.0100.00222.96
5.3.130.0110.00122.96
5.3.120.0070.00522.96
5.3.110.0070.00422.96
5.3.100.0150.00122.96
5.3.90.0030.00822.96
5.3.80.0080.00222.96
5.3.70.0050.00522.96
5.3.60.0090.00322.96
5.3.50.0050.00522.96
5.3.40.0020.00822.96
5.3.30.0040.00622.96
5.3.20.0060.00522.96
5.3.10.0020.00822.96
5.3.00.0060.00322.96
5.2.170.0030.00622.96
5.2.160.0060.00322.96
5.2.150.0070.00422.96
5.2.140.0040.00722.96
5.2.130.0060.00322.96
5.2.120.0030.00822.96
5.2.110.0050.00522.96
5.2.100.0050.00522.96
5.2.90.0040.00422.96
5.2.80.0030.00822.96
5.2.70.0020.00722.96
5.2.60.0030.00822.96
5.2.50.0060.00522.96
5.2.40.0070.00422.96
5.2.30.0150.00122.96
5.2.20.0150.00222.96
5.2.10.0070.01022.96
5.2.00.0080.00922.96
5.1.60.0110.00522.96
5.1.50.0140.00222.96
5.1.40.0110.00322.96
5.1.30.0130.00222.96
5.1.20.0150.00222.96
5.1.10.0100.00422.96
5.1.00.0100.00322.96
5.0.50.0090.00322.96
5.0.40.0120.00022.96
5.0.30.0080.00722.96
5.0.20.0060.00722.96
5.0.10.0050.00722.96
5.0.00.0110.00022.96
4.4.90.0060.00022.96
4.4.80.0050.00122.96
4.4.70.0070.00122.96
4.4.60.0060.00022.96
4.4.50.0080.00022.96
4.4.40.0060.00222.96
4.4.30.0080.00022.96
4.4.20.0070.00222.96
4.4.10.0080.00122.96
4.4.00.0040.00422.96
4.3.110.0090.00022.96
4.3.100.0070.00122.96
4.3.90.0030.00522.96
4.3.80.0000.00822.96
4.3.70.0080.00122.96
4.3.60.0080.00022.96
4.3.50.0030.00622.96
4.3.40.0060.00122.96
4.3.30.0040.00122.96
4.3.20.0050.00222.96
4.3.10.0040.00122.96
4.3.00.0050.00222.96

preferences:
47.61 ms | 403 KiB | 5 Q