3v4l.org

run code in 300+ PHP versions simultaneously
<?php // $this->last_result analogue in WPDB for 1000 posts' "SELECT meta_key, meta_value WHERE...." $last_result = array_fill( 0, 2000, (object) [ 'meta_key' => 'hello_who', 'meta_value' => str_repeat( 'World and WordPress ', 20 ), ] ); const ARRAY_N = 0b0; $output = 0b0; // Startup engines; number_format( hrtime( true ) / 1e9 ); $new_array = []; foreach ( (array) $last_result as $row ) { // ...integer-keyed row arrays. $new_array[] = array_values( get_object_vars( $row ) ); } $new_array = []; foreach ( (array) $last_result as $row ) { // ...column name-keyed row arrays. $new_array[] = get_object_vars( $row ); } $new_array = []; // Test. $new_array = []; $t = hrtime( true ); foreach ( (array) $last_result as $row ) { if ( ARRAY_N === $output ) { // ...integer-keyed row arrays. $new_array[] = array_values( get_object_vars( $row ) ); } else { // ...column name-keyed row arrays. $new_array[] = get_object_vars( $row ); } } echo 'Old ARRAY_N: ', number_format( ( hrtime( true ) - $t ) / 1e9, 5 ).'s', "\n"; $new_array = []; $t = hrtime( true ); if ( ARRAY_N === $output ) { foreach ( (array) $last_result as $row ) { // ...integer-keyed row arrays. $new_array[] = array_values( get_object_vars( $row ) ); } } else { foreach ( (array) $last_result as $row ) { // ...column name-keyed row arrays. $new_array[] = get_object_vars( $row ); } } echo 'New ARRAY_N: ', number_format( ( hrtime( true ) - $t ) / 1e9, 5 ).'s', "\n"; // Test ARRAY_A now. $output = 0b1; $new_array = []; $t = hrtime( true ); foreach ( (array) $last_result as $row ) { if ( ARRAY_N === $output ) { // ...integer-keyed row arrays. $new_array[] = array_values( get_object_vars( $row ) ); } else { // ...column name-keyed row arrays. $new_array[] = get_object_vars( $row ); } } echo 'Old ARRAY_A: ', number_format( ( hrtime( true ) - $t ) / 1e9, 5 ).'s', "\n"; $new_array = []; $t = hrtime( true ); if ( ARRAY_N === $output ) { foreach ( (array) $last_result as $row ) { // ...integer-keyed row arrays. $new_array[] = array_values( get_object_vars( $row ) ); } } else { foreach ( (array) $last_result as $row ) { // ...column name-keyed row arrays. $new_array[] = get_object_vars( $row ); } } echo 'New ARRAY_A: ', number_format( ( hrtime( true ) - $t ) / 1e9, 5 ).'s', "\n";
Output for 8.4.2
Old ARRAY_N: 0.00028s New ARRAY_N: 0.00022s Old ARRAY_A: 0.00014s New ARRAY_A: 0.00011s
Output for 8.4.1
Old ARRAY_N: 0.00025s New ARRAY_N: 0.00024s Old ARRAY_A: 0.00012s New ARRAY_A: 0.00010s
Output for 8.3.15
Old ARRAY_N: 0.00026s New ARRAY_N: 0.00024s Old ARRAY_A: 0.00014s New ARRAY_A: 0.00017s
Output for 8.3.14
Old ARRAY_N: 0.00011s New ARRAY_N: 0.00009s Old ARRAY_A: 0.00006s New ARRAY_A: 0.00005s
Output for 8.3.13
Old ARRAY_N: 0.00014s New ARRAY_N: 0.00009s Old ARRAY_A: 0.00006s New ARRAY_A: 0.00007s
Output for 8.3.10, 8.3.12
Old ARRAY_N: 0.00011s New ARRAY_N: 0.00009s Old ARRAY_A: 0.00005s New ARRAY_A: 0.00004s
Output for 8.3.11
Old ARRAY_N: 0.00011s New ARRAY_N: 0.00008s Old ARRAY_A: 0.00007s New ARRAY_A: 0.00004s
Output for 8.3.9
Old ARRAY_N: 0.00015s New ARRAY_N: 0.00016s Old ARRAY_A: 0.00011s New ARRAY_A: 0.00008s
Output for 7.4.7, 8.1.1, 8.3.8
Old ARRAY_N: 0.00020s New ARRAY_N: 0.00017s Old ARRAY_A: 0.00012s New ARRAY_A: 0.00009s
Output for 8.3.7
Old ARRAY_N: 0.00033s New ARRAY_N: 0.00023s Old ARRAY_A: 0.00019s New ARRAY_A: 0.00012s
Output for 8.3.6
Old ARRAY_N: 0.00024s New ARRAY_N: 0.00016s Old ARRAY_A: 0.00010s New ARRAY_A: 0.00008s
Output for 8.3.5
Old ARRAY_N: 0.00034s New ARRAY_N: 0.00024s Old ARRAY_A: 0.00014s New ARRAY_A: 0.00010s
Output for 8.3.4
Old ARRAY_N: 0.00023s New ARRAY_N: 0.00018s Old ARRAY_A: 0.00011s New ARRAY_A: 0.00010s
Output for 8.3.3
Old ARRAY_N: 0.00023s New ARRAY_N: 0.00015s Old ARRAY_A: 0.00010s New ARRAY_A: 0.00008s
Output for 8.3.0, 8.3.2
Old ARRAY_N: 0.00010s New ARRAY_N: 0.00009s Old ARRAY_A: 0.00006s New ARRAY_A: 0.00006s
Output for 8.3.1
Old ARRAY_N: 0.00010s New ARRAY_N: 0.00008s Old ARRAY_A: 0.00006s New ARRAY_A: 0.00004s
Output for 8.2.26
Old ARRAY_N: 0.00025s New ARRAY_N: 0.00021s Old ARRAY_A: 0.00013s New ARRAY_A: 0.00011s
Output for 8.1.30, 8.2.25
Old ARRAY_N: 0.00012s New ARRAY_N: 0.00008s Old ARRAY_A: 0.00005s New ARRAY_A: 0.00004s
Output for 8.2.24
Old ARRAY_N: 0.00012s New ARRAY_N: 0.00008s Old ARRAY_A: 0.00005s New ARRAY_A: 0.00005s
Output for 8.2.23
Old ARRAY_N: 0.00011s New ARRAY_N: 0.00009s Old ARRAY_A: 0.00005s New ARRAY_A: 0.00005s
Output for 8.2.22
Old ARRAY_N: 0.00011s New ARRAY_N: 0.00009s Old ARRAY_A: 0.00006s New ARRAY_A: 0.00004s
Output for 8.2.21
Old ARRAY_N: 0.00013s New ARRAY_N: 0.00011s Old ARRAY_A: 0.00007s New ARRAY_A: 0.00007s
Output for 8.2.20
Old ARRAY_N: 0.00012s New ARRAY_N: 0.00011s Old ARRAY_A: 0.00007s New ARRAY_A: 0.00006s
Output for 8.2.19
Old ARRAY_N: 0.00021s New ARRAY_N: 0.00016s Old ARRAY_A: 0.00010s New ARRAY_A: 0.00010s
Output for 8.2.18
Old ARRAY_N: 0.00029s New ARRAY_N: 0.00030s Old ARRAY_A: 0.00021s New ARRAY_A: 0.00020s
Output for 8.2.17
Old ARRAY_N: 0.00019s New ARRAY_N: 0.00030s Old ARRAY_A: 0.00010s New ARRAY_A: 0.00008s
Output for 8.2.16
Old ARRAY_N: 0.00023s New ARRAY_N: 0.00021s Old ARRAY_A: 0.00014s New ARRAY_A: 0.00013s
Output for 8.1.26 - 8.1.27, 8.2.15
Old ARRAY_N: 0.00010s New ARRAY_N: 0.00008s Old ARRAY_A: 0.00005s New ARRAY_A: 0.00005s
Output for 8.2.14
Old ARRAY_N: 0.00011s New ARRAY_N: 0.00011s Old ARRAY_A: 0.00006s New ARRAY_A: 0.00006s
Output for 8.2.12 - 8.2.13
Old ARRAY_N: 0.00010s New ARRAY_N: 0.00008s Old ARRAY_A: 0.00005s New ARRAY_A: 0.00004s
Output for 8.2.11
Old ARRAY_N: 0.00020s New ARRAY_N: 0.00018s Old ARRAY_A: 0.00011s New ARRAY_A: 0.00011s
Output for 8.2.10
Old ARRAY_N: 0.00016s New ARRAY_N: 0.00025s Old ARRAY_A: 0.00009s New ARRAY_A: 0.00007s
Output for 8.2.9
Old ARRAY_N: 0.00014s New ARRAY_N: 0.00011s Old ARRAY_A: 0.00009s New ARRAY_A: 0.00010s
Output for 8.2.8
Old ARRAY_N: 0.00015s New ARRAY_N: 0.00012s Old ARRAY_A: 0.00009s New ARRAY_A: 0.00008s
Output for 8.2.7
Old ARRAY_N: 0.00014s New ARRAY_N: 0.00012s Old ARRAY_A: 0.00010s New ARRAY_A: 0.00007s
Output for 8.2.5 - 8.2.6
Old ARRAY_N: 0.00015s New ARRAY_N: 0.00012s Old ARRAY_A: 0.00008s New ARRAY_A: 0.00006s
Output for 8.2.4
Old ARRAY_N: 0.00015s New ARRAY_N: 0.00012s Old ARRAY_A: 0.00010s New ARRAY_A: 0.00007s
Output for 8.2.3
Old ARRAY_N: 0.00014s New ARRAY_N: 0.00012s Old ARRAY_A: 0.00008s New ARRAY_A: 0.00006s
Output for 8.2.2
Old ARRAY_N: 0.00017s New ARRAY_N: 0.00011s Old ARRAY_A: 0.00009s New ARRAY_A: 0.00006s
Output for 8.1.20, 8.1.22, 8.2.1
Old ARRAY_N: 0.00015s New ARRAY_N: 0.00011s Old ARRAY_A: 0.00009s New ARRAY_A: 0.00006s
Output for 8.2.0
Old ARRAY_N: 0.00015s New ARRAY_N: 0.00011s Old ARRAY_A: 0.00008s New ARRAY_A: 0.00006s
Output for 8.1.31
Old ARRAY_N: 0.00025s New ARRAY_N: 0.00020s Old ARRAY_A: 0.00013s New ARRAY_A: 0.00011s
Output for 8.1.29
Old ARRAY_N: 0.00012s New ARRAY_N: 0.00016s Old ARRAY_A: 0.00011s New ARRAY_A: 0.00009s
Output for 8.1.28
Old ARRAY_N: 0.00024s New ARRAY_N: 0.00019s Old ARRAY_A: 0.00012s New ARRAY_A: 0.00011s
Output for 8.1.25
Old ARRAY_N: 0.00011s New ARRAY_N: 0.00009s Old ARRAY_A: 0.00006s New ARRAY_A: 0.00006s
Output for 8.1.24
Old ARRAY_N: 0.00019s New ARRAY_N: 0.00018s Old ARRAY_A: 0.00011s New ARRAY_A: 0.00010s
Output for 8.1.23
Old ARRAY_N: 0.00015s New ARRAY_N: 0.00011s Old ARRAY_A: 0.00010s New ARRAY_A: 0.00006s
Output for 8.1.21
Old ARRAY_N: 0.00016s New ARRAY_N: 0.00011s Old ARRAY_A: 0.00009s New ARRAY_A: 0.00006s
Output for 8.1.19
Old ARRAY_N: 0.00018s New ARRAY_N: 0.00011s Old ARRAY_A: 0.00009s New ARRAY_A: 0.00006s
Output for 8.1.18
Old ARRAY_N: 0.00016s New ARRAY_N: 0.00014s Old ARRAY_A: 0.00009s New ARRAY_A: 0.00007s
Output for 8.1.17
Old ARRAY_N: 0.00018s New ARRAY_N: 0.00031s Old ARRAY_A: 0.00011s New ARRAY_A: 0.00007s
Output for 8.1.16
Old ARRAY_N: 0.00016s New ARRAY_N: 0.00013s Old ARRAY_A: 0.00010s New ARRAY_A: 0.00007s
Output for 8.1.15
Old ARRAY_N: 0.00016s New ARRAY_N: 0.00013s Old ARRAY_A: 0.00009s New ARRAY_A: 0.00007s
Output for 8.0.14, 8.1.14
Old ARRAY_N: 0.00016s New ARRAY_N: 0.00012s Old ARRAY_A: 0.00010s New ARRAY_A: 0.00006s
Output for 8.1.13
Old ARRAY_N: 0.00018s New ARRAY_N: 0.00017s Old ARRAY_A: 0.00012s New ARRAY_A: 0.00008s
Output for 8.1.12
Old ARRAY_N: 0.00016s New ARRAY_N: 0.00013s Old ARRAY_A: 0.00016s New ARRAY_A: 0.00008s
Output for 8.1.11
Old ARRAY_N: 0.00016s New ARRAY_N: 0.00013s Old ARRAY_A: 0.00012s New ARRAY_A: 0.00007s
Output for 8.1.9 - 8.1.10
Old ARRAY_N: 0.00023s New ARRAY_N: 0.00018s Old ARRAY_A: 0.00013s New ARRAY_A: 0.00010s
Output for 8.1.8
Old ARRAY_N: 0.00022s New ARRAY_N: 0.00016s Old ARRAY_A: 0.00011s New ARRAY_A: 0.00009s
Output for 8.1.7
Old ARRAY_N: 0.00021s New ARRAY_N: 0.00018s Old ARRAY_A: 0.00012s New ARRAY_A: 0.00009s
Output for 8.1.6
Old ARRAY_N: 0.00015s New ARRAY_N: 0.00012s Old ARRAY_A: 0.00009s New ARRAY_A: 0.00007s
Output for 7.4.27, 8.1.5
Old ARRAY_N: 0.00020s New ARRAY_N: 0.00017s Old ARRAY_A: 0.00012s New ARRAY_A: 0.00010s
Output for 8.1.4
Old ARRAY_N: 0.00020s New ARRAY_N: 0.00783s Old ARRAY_A: 0.00012s New ARRAY_A: 0.00012s
Output for 8.1.3
Old ARRAY_N: 0.00022s New ARRAY_N: 0.00017s Old ARRAY_A: 0.00013s New ARRAY_A: 0.00009s
Output for 8.1.2
Old ARRAY_N: 0.00014s New ARRAY_N: 0.00013s Old ARRAY_A: 0.00010s New ARRAY_A: 0.00008s
Output for 8.1.0
Old ARRAY_N: 0.00017s New ARRAY_N: 0.00014s Old ARRAY_A: 0.00010s New ARRAY_A: 0.00010s
Output for 8.0.30
Old ARRAY_N: 0.00016s New ARRAY_N: 0.00011s Old ARRAY_A: 0.00007s New ARRAY_A: 0.00006s
Output for 8.0.29
Old ARRAY_N: 0.00016s New ARRAY_N: 0.00012s Old ARRAY_A: 0.00010s New ARRAY_A: 0.00008s
Output for 8.0.2, 8.0.24, 8.0.26, 8.0.28
Old ARRAY_N: 0.00016s New ARRAY_N: 0.00012s Old ARRAY_A: 0.00009s New ARRAY_A: 0.00006s
Output for 8.0.27
Old ARRAY_N: 0.00016s New ARRAY_N: 0.00012s Old ARRAY_A: 0.00009s New ARRAY_A: 0.00007s
Output for 8.0.25
Old ARRAY_N: 0.00017s New ARRAY_N: 0.00012s Old ARRAY_A: 0.00010s New ARRAY_A: 0.00007s
Output for 7.4.5, 8.0.23
Old ARRAY_N: 0.00021s New ARRAY_N: 0.00017s Old ARRAY_A: 0.00012s New ARRAY_A: 0.00010s
Output for 8.0.22
Old ARRAY_N: 0.00022s New ARRAY_N: 0.00020s Old ARRAY_A: 0.00012s New ARRAY_A: 0.00009s
Output for 8.0.21
Old ARRAY_N: 0.00015s New ARRAY_N: 0.00011s Old ARRAY_A: 0.00010s New ARRAY_A: 0.00010s
Output for 8.0.20
Old ARRAY_N: 0.00023s New ARRAY_N: 0.00017s Old ARRAY_A: 0.00014s New ARRAY_A: 0.00011s
Output for 8.0.19
Old ARRAY_N: 0.00018s New ARRAY_N: 0.00014s Old ARRAY_A: 0.00012s New ARRAY_A: 0.00008s
Output for 8.0.18
Old ARRAY_N: 0.00017s New ARRAY_N: 0.00012s Old ARRAY_A: 0.00017s New ARRAY_A: 0.00010s
Output for 8.0.17
Old ARRAY_N: 0.00022s New ARRAY_N: 0.00020s Old ARRAY_A: 0.00011s New ARRAY_A: 0.00009s
Output for 8.0.16
Old ARRAY_N: 0.00029s New ARRAY_N: 0.00017s Old ARRAY_A: 0.00012s New ARRAY_A: 0.00010s
Output for 8.0.15
Old ARRAY_N: 0.00022s New ARRAY_N: 0.00022s Old ARRAY_A: 0.00014s New ARRAY_A: 0.00010s
Output for 8.0.13
Old ARRAY_N: 0.00020s New ARRAY_N: 0.00016s Old ARRAY_A: 0.00011s New ARRAY_A: 0.00013s
Output for 8.0.12
Old ARRAY_N: 0.00022s New ARRAY_N: 0.00018s Old ARRAY_A: 0.00016s New ARRAY_A: 0.00012s
Output for 8.0.11
Old ARRAY_N: 0.00022s New ARRAY_N: 0.00017s Old ARRAY_A: 0.00012s New ARRAY_A: 0.00009s
Output for 8.0.10
Old ARRAY_N: 0.00016s New ARRAY_N: 0.00012s Old ARRAY_A: 0.00008s New ARRAY_A: 0.00006s
Output for 8.0.9
Old ARRAY_N: 0.00031s New ARRAY_N: 0.00027s Old ARRAY_A: 0.00012s New ARRAY_A: 0.00009s
Output for 8.0.8
Old ARRAY_N: 0.00020s New ARRAY_N: 0.00021s Old ARRAY_A: 0.00011s New ARRAY_A: 0.00009s
Output for 8.0.7
Old ARRAY_N: 0.00026s New ARRAY_N: 0.00021s Old ARRAY_A: 0.00015s New ARRAY_A: 0.00012s
Output for 8.0.6
Old ARRAY_N: 0.00175s New ARRAY_N: 0.00017s Old ARRAY_A: 0.00011s New ARRAY_A: 0.00009s
Output for 8.0.5
Old ARRAY_N: 0.00021s New ARRAY_N: 0.00016s Old ARRAY_A: 0.00108s New ARRAY_A: 0.00012s
Output for 8.0.3
Old ARRAY_N: 0.00016s New ARRAY_N: 0.00014s Old ARRAY_A: 0.00011s New ARRAY_A: 0.00008s
Output for 8.0.1
Old ARRAY_N: 0.00021s New ARRAY_N: 0.00016s Old ARRAY_A: 0.00016s New ARRAY_A: 0.00009s
Output for 7.4.33
Old ARRAY_N: 0.00016s New ARRAY_N: 0.00013s Old ARRAY_A: 0.00009s New ARRAY_A: 0.00006s
Output for 7.4.32
Old ARRAY_N: 0.00016s New ARRAY_N: 0.00012s Old ARRAY_A: 0.00010s New ARRAY_A: 0.00010s
Output for 7.4.30
Old ARRAY_N: 0.00019s New ARRAY_N: 0.00017s Old ARRAY_A: 0.00012s New ARRAY_A: 0.00009s
Output for 7.4.29
Old ARRAY_N: 0.00025s New ARRAY_N: 0.00020s Old ARRAY_A: 0.00013s New ARRAY_A: 0.00009s
Output for 7.4.28
Old ARRAY_N: 0.00022s New ARRAY_N: 0.00017s Old ARRAY_A: 0.00010s New ARRAY_A: 0.00010s
Output for 7.4.26
Old ARRAY_N: 0.00021s New ARRAY_N: 0.00018s Old ARRAY_A: 0.00012s New ARRAY_A: 0.00013s
Output for 7.4.25
Old ARRAY_N: 0.00033s New ARRAY_N: 0.00016s Old ARRAY_A: 0.00011s New ARRAY_A: 0.00009s
Output for 7.4.24
Old ARRAY_N: 0.00016s New ARRAY_N: 0.00015s Old ARRAY_A: 0.00012s New ARRAY_A: 0.00009s
Output for 7.4.23
Old ARRAY_N: 0.00016s New ARRAY_N: 0.00014s Old ARRAY_A: 0.00011s New ARRAY_A: 0.00009s
Output for 7.4.22
Old ARRAY_N: 0.00015s New ARRAY_N: 0.00012s Old ARRAY_A: 0.00009s New ARRAY_A: 0.00006s
Output for 7.4.21
Old ARRAY_N: 0.00024s New ARRAY_N: 0.00018s Old ARRAY_A: 0.00011s New ARRAY_A: 0.00012s
Output for 7.4.20
Old ARRAY_N: 0.00018s New ARRAY_N: 0.00013s Old ARRAY_A: 0.00010s New ARRAY_A: 0.00009s
Output for 7.4.19
Old ARRAY_N: 0.00019s New ARRAY_N: 0.00015s Old ARRAY_A: 0.00014s New ARRAY_A: 0.00010s
Output for 7.4.18
Old ARRAY_N: 0.00082s New ARRAY_N: 0.00019s Old ARRAY_A: 0.00014s New ARRAY_A: 0.00012s
Output for 7.4.16
Old ARRAY_N: 0.00020s New ARRAY_N: 0.00014s Old ARRAY_A: 0.00012s New ARRAY_A: 0.00009s
Output for 7.4.15
Old ARRAY_N: 0.00021s New ARRAY_N: 0.00016s Old ARRAY_A: 0.00010s New ARRAY_A: 0.00008s
Output for 7.4.14
Old ARRAY_N: 0.00020s New ARRAY_N: 0.00017s Old ARRAY_A: 0.00013s New ARRAY_A: 0.00009s
Output for 7.4.13
Old ARRAY_N: 0.00015s New ARRAY_N: 0.00016s Old ARRAY_A: 0.00009s New ARRAY_A: 0.00006s
Output for 7.4.12
Old ARRAY_N: 0.00033s New ARRAY_N: 0.00024s Old ARRAY_A: 0.00018s New ARRAY_A: 0.00014s
Output for 7.4.11
Old ARRAY_N: 0.00017s New ARRAY_N: 0.00013s Old ARRAY_A: 0.00010s New ARRAY_A: 0.00007s
Output for 7.4.10
Old ARRAY_N: 0.00021s New ARRAY_N: 0.00018s Old ARRAY_A: 0.00012s New ARRAY_A: 0.00010s
Output for 7.4.9
Old ARRAY_N: 0.00019s New ARRAY_N: 0.00017s Old ARRAY_A: 0.00009s New ARRAY_A: 0.00008s
Output for 7.4.8
Old ARRAY_N: 0.00022s New ARRAY_N: 0.00017s Old ARRAY_A: 0.00011s New ARRAY_A: 0.00010s
Output for 7.4.6
Old ARRAY_N: 0.00021s New ARRAY_N: 0.00017s Old ARRAY_A: 0.00010s New ARRAY_A: 0.00009s
Output for 7.4.4
Old ARRAY_N: 0.00022s New ARRAY_N: 0.00022s Old ARRAY_A: 0.00012s New ARRAY_A: 0.00010s
Output for 7.4.3
Old ARRAY_N: 0.00021s New ARRAY_N: 0.00018s Old ARRAY_A: 0.00011s New ARRAY_A: 0.00009s
Output for 7.4.2
Old ARRAY_N: 0.00016s New ARRAY_N: 0.00014s Old ARRAY_A: 0.00009s New ARRAY_A: 0.00008s
Output for 7.4.1
Old ARRAY_N: 0.00017s New ARRAY_N: 0.00012s Old ARRAY_A: 0.00009s New ARRAY_A: 0.00008s
Output for 7.4.0
Old ARRAY_N: 0.00022s New ARRAY_N: 0.00017s Old ARRAY_A: 0.00012s New ARRAY_A: 0.00010s

preferences:
112.87 ms | 584 KiB | 5 Q