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 git.master
Old ARRAY_N: 0.00017s New ARRAY_N: 0.00016s Old ARRAY_A: 0.00009s New ARRAY_A: 0.00007s
Output for git.master_jit
Old ARRAY_N: 0.00014s New ARRAY_N: 0.00011s Old ARRAY_A: 0.00008s New ARRAY_A: 0.00006s
Output for rfc.property-hooks
Old ARRAY_N: 0.00012s New ARRAY_N: 0.00009s Old ARRAY_A: 0.00007s New ARRAY_A: 0.00007s

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
36.36 ms | 407 KiB | 5 Q