3v4l.org

run code in 300+ PHP versions simultaneously
<?php // $this->last_result analogue in WPDB for 80000 posts' "SELECT meta_key, meta_value WHERE...." $last_result = array_fill( 0, 80000, (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.00533s New ARRAY_N: 0.00462s Old ARRAY_A: 0.00314s New ARRAY_A: 0.00277s
Output for 8.4.1
Old ARRAY_N: 0.01335s New ARRAY_N: 0.01228s Old ARRAY_A: 0.00756s New ARRAY_A: 0.00423s
Output for 8.3.15
Old ARRAY_N: 0.00661s New ARRAY_N: 0.00529s Old ARRAY_A: 0.00301s New ARRAY_A: 0.00257s
Output for 8.3.14
Old ARRAY_N: 0.00536s New ARRAY_N: 0.00456s Old ARRAY_A: 0.00307s New ARRAY_A: 0.00255s
Output for 8.3.13
Old ARRAY_N: 0.00516s New ARRAY_N: 0.00443s Old ARRAY_A: 0.00298s New ARRAY_A: 0.00258s
Output for 8.3.12
Old ARRAY_N: 0.00576s New ARRAY_N: 0.00487s Old ARRAY_A: 0.00311s New ARRAY_A: 0.00276s
Output for 8.3.11
Old ARRAY_N: 0.00740s New ARRAY_N: 0.00653s Old ARRAY_A: 0.00427s New ARRAY_A: 0.00334s
Output for 8.3.10
Old ARRAY_N: 0.00540s New ARRAY_N: 0.00419s Old ARRAY_A: 0.00276s New ARRAY_A: 0.00228s
Output for 8.3.9
Old ARRAY_N: 0.00508s New ARRAY_N: 0.00417s Old ARRAY_A: 0.00267s New ARRAY_A: 0.00222s
Output for 8.3.8
Old ARRAY_N: 0.00574s New ARRAY_N: 0.00516s Old ARRAY_A: 0.00363s New ARRAY_A: 0.00322s
Output for 8.3.7
Old ARRAY_N: 0.01042s New ARRAY_N: 0.00845s Old ARRAY_A: 0.00566s New ARRAY_A: 0.00494s
Output for 8.3.6
Old ARRAY_N: 0.01236s New ARRAY_N: 0.00903s Old ARRAY_A: 0.00571s New ARRAY_A: 0.00490s
Output for 8.3.5
Old ARRAY_N: 0.00984s New ARRAY_N: 0.00756s Old ARRAY_A: 0.00500s New ARRAY_A: 0.00421s
Output for 8.3.4
Old ARRAY_N: 0.00909s New ARRAY_N: 0.00800s Old ARRAY_A: 0.00568s New ARRAY_A: 0.00506s
Output for 8.3.3
Old ARRAY_N: 0.00975s New ARRAY_N: 0.00814s Old ARRAY_A: 0.00572s New ARRAY_A: 0.00493s
Output for 8.3.2
Old ARRAY_N: 0.00506s New ARRAY_N: 0.00437s Old ARRAY_A: 0.00308s New ARRAY_A: 0.00268s
Output for 8.3.1
Old ARRAY_N: 0.00507s New ARRAY_N: 0.00450s Old ARRAY_A: 0.00311s New ARRAY_A: 0.00272s
Output for 8.3.0
Old ARRAY_N: 0.00397s New ARRAY_N: 0.00358s Old ARRAY_A: 0.00229s New ARRAY_A: 0.00190s
Output for 8.2.26
Old ARRAY_N: 0.00588s New ARRAY_N: 0.00480s Old ARRAY_A: 0.00308s New ARRAY_A: 0.00273s
Output for 8.2.25
Old ARRAY_N: 0.00564s New ARRAY_N: 0.00552s Old ARRAY_A: 0.00390s New ARRAY_A: 0.00303s
Output for 8.2.24
Old ARRAY_N: 0.00675s New ARRAY_N: 0.00654s Old ARRAY_A: 0.00367s New ARRAY_A: 0.00292s
Output for 8.2.23
Old ARRAY_N: 0.00593s New ARRAY_N: 0.00477s Old ARRAY_A: 0.00314s New ARRAY_A: 0.00271s
Output for 8.2.22
Old ARRAY_N: 0.00570s New ARRAY_N: 0.00492s Old ARRAY_A: 0.00372s New ARRAY_A: 0.00316s
Output for 8.2.21
Old ARRAY_N: 0.00523s New ARRAY_N: 0.00448s Old ARRAY_A: 0.00298s New ARRAY_A: 0.00256s
Output for 8.2.20
Old ARRAY_N: 0.00578s New ARRAY_N: 0.00516s Old ARRAY_A: 0.00360s New ARRAY_A: 0.00312s
Output for 8.2.19
Old ARRAY_N: 0.00955s New ARRAY_N: 0.00853s Old ARRAY_A: 0.00568s New ARRAY_A: 0.00483s
Output for 8.2.18
Old ARRAY_N: 0.01088s New ARRAY_N: 0.00877s Old ARRAY_A: 0.00610s New ARRAY_A: 0.00518s
Output for 8.2.17
Old ARRAY_N: 0.00916s New ARRAY_N: 0.00799s Old ARRAY_A: 0.00584s New ARRAY_A: 0.00499s
Output for 8.2.16
Old ARRAY_N: 0.00755s New ARRAY_N: 0.00646s Old ARRAY_A: 0.00427s New ARRAY_A: 0.00345s
Output for 8.2.15
Old ARRAY_N: 0.00491s New ARRAY_N: 0.00436s Old ARRAY_A: 0.00331s New ARRAY_A: 0.00262s
Output for 8.2.14
Old ARRAY_N: 0.00502s New ARRAY_N: 0.00445s Old ARRAY_A: 0.00307s New ARRAY_A: 0.00265s
Output for 8.2.13
Old ARRAY_N: 0.00503s New ARRAY_N: 0.00432s Old ARRAY_A: 0.00305s New ARRAY_A: 0.00265s
Output for 8.2.12
Old ARRAY_N: 0.00496s New ARRAY_N: 0.00445s Old ARRAY_A: 0.00302s New ARRAY_A: 0.00261s
Output for 8.2.11
Old ARRAY_N: 0.00797s New ARRAY_N: 0.00729s Old ARRAY_A: 0.00443s New ARRAY_A: 0.00404s
Output for 8.2.10
Old ARRAY_N: 0.01080s New ARRAY_N: 0.00762s Old ARRAY_A: 0.00574s New ARRAY_A: 0.00530s
Output for 8.2.9
Old ARRAY_N: 0.00635s New ARRAY_N: 0.00553s Old ARRAY_A: 0.00380s New ARRAY_A: 0.00294s
Output for 8.2.8
Old ARRAY_N: 0.00640s New ARRAY_N: 0.00554s Old ARRAY_A: 0.00380s New ARRAY_A: 0.00294s
Output for 8.2.7
Old ARRAY_N: 0.00677s New ARRAY_N: 0.00595s Old ARRAY_A: 0.00389s New ARRAY_A: 0.00303s
Output for 8.2.6
Old ARRAY_N: 0.00643s New ARRAY_N: 0.00589s Old ARRAY_A: 0.00393s New ARRAY_A: 0.00297s
Output for 8.2.5
Old ARRAY_N: 0.00637s New ARRAY_N: 0.00571s Old ARRAY_A: 0.00389s New ARRAY_A: 0.00298s
Output for 8.2.4
Old ARRAY_N: 0.00600s New ARRAY_N: 0.00518s Old ARRAY_A: 0.00380s New ARRAY_A: 0.00290s
Output for 8.2.3
Old ARRAY_N: 0.00602s New ARRAY_N: 0.00534s Old ARRAY_A: 0.00380s New ARRAY_A: 0.00322s
Output for 8.2.2
Old ARRAY_N: 0.00684s New ARRAY_N: 0.00559s Old ARRAY_A: 0.00400s New ARRAY_A: 0.00292s
Output for 8.2.1
Old ARRAY_N: 0.00757s New ARRAY_N: 0.00823s Old ARRAY_A: 0.00515s New ARRAY_A: 0.00360s
Output for 8.2.0
Old ARRAY_N: 0.00613s New ARRAY_N: 0.00553s Old ARRAY_A: 0.00392s New ARRAY_A: 0.00283s
Output for 8.1.31
Old ARRAY_N: 0.00662s New ARRAY_N: 0.00577s Old ARRAY_A: 0.00430s New ARRAY_A: 0.00426s
Output for 8.1.30
Old ARRAY_N: 0.00717s New ARRAY_N: 0.00609s Old ARRAY_A: 0.00448s New ARRAY_A: 0.00406s
Output for 8.1.29
Old ARRAY_N: 0.01057s New ARRAY_N: 0.00885s Old ARRAY_A: 0.00520s New ARRAY_A: 0.00477s
Output for 8.1.28
Old ARRAY_N: 0.01270s New ARRAY_N: 0.01123s Old ARRAY_A: 0.00823s New ARRAY_A: 0.00779s
Output for 8.1.2 - 8.1.27
Fatal error: Out of memory (allocated 31465472) (tried to allocate 20480 bytes) in /in/6OOHn on line 17 mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory
Process exited with code 255.
Output for 8.1.1
Old ARRAY_N: 0.00703s New ARRAY_N: 0.00602s Old ARRAY_A: 0.00427s New ARRAY_A: 0.00294s
Output for 8.1.0
Old ARRAY_N: 0.00673s New ARRAY_N: 0.00608s Old ARRAY_A: 0.00415s New ARRAY_A: 0.00296s
Output for 8.0.30
Old ARRAY_N: 0.00666s New ARRAY_N: 0.00561s Old ARRAY_A: 0.00376s New ARRAY_A: 0.00312s
Output for 8.0.29
Old ARRAY_N: 0.00936s New ARRAY_N: 0.00966s Old ARRAY_A: 0.00419s New ARRAY_A: 0.00322s
Output for 8.0.28
Old ARRAY_N: 0.01100s New ARRAY_N: 0.00982s Old ARRAY_A: 0.00499s New ARRAY_A: 0.00353s
Output for 8.0.27
Old ARRAY_N: 0.00917s New ARRAY_N: 0.00776s Old ARRAY_A: 0.00428s New ARRAY_A: 0.00328s
Output for 8.0.26
Old ARRAY_N: 0.01012s New ARRAY_N: 0.00818s Old ARRAY_A: 0.00427s New ARRAY_A: 0.00339s
Output for 8.0.25
Old ARRAY_N: 0.00759s New ARRAY_N: 0.00598s Old ARRAY_A: 0.00450s New ARRAY_A: 0.00292s
Output for 8.0.24
Old ARRAY_N: 0.00717s New ARRAY_N: 0.00592s Old ARRAY_A: 0.00445s New ARRAY_A: 0.00298s
Output for 8.0.23
Old ARRAY_N: 0.00668s New ARRAY_N: 0.00607s Old ARRAY_A: 0.00380s New ARRAY_A: 0.00294s
Output for 8.0.22
Old ARRAY_N: 0.00677s New ARRAY_N: 0.00567s Old ARRAY_A: 0.00427s New ARRAY_A: 0.00296s
Output for 8.0.21
Old ARRAY_N: 0.00664s New ARRAY_N: 0.00568s Old ARRAY_A: 0.00392s New ARRAY_A: 0.00296s
Output for 8.0.20
Old ARRAY_N: 0.00653s New ARRAY_N: 0.00556s Old ARRAY_A: 0.00419s New ARRAY_A: 0.00293s
Output for 8.0.19
Old ARRAY_N: 0.00702s New ARRAY_N: 0.00570s Old ARRAY_A: 0.00438s New ARRAY_A: 0.00302s
Output for 8.0.18
Old ARRAY_N: 0.00703s New ARRAY_N: 0.00632s Old ARRAY_A: 0.00429s New ARRAY_A: 0.00298s
Output for 8.0.17
Old ARRAY_N: 0.01161s New ARRAY_N: 0.00851s Old ARRAY_A: 0.00422s New ARRAY_A: 0.00292s
Output for 8.0.16
Old ARRAY_N: 0.00645s New ARRAY_N: 0.00590s Old ARRAY_A: 0.00383s New ARRAY_A: 0.00304s
Output for 8.0.15
Old ARRAY_N: 0.00698s New ARRAY_N: 0.00661s Old ARRAY_A: 0.00404s New ARRAY_A: 0.00296s
Output for 8.0.14
Old ARRAY_N: 0.00697s New ARRAY_N: 0.00600s Old ARRAY_A: 0.00437s New ARRAY_A: 0.00296s
Output for 8.0.13
Old ARRAY_N: 0.00675s New ARRAY_N: 0.00597s Old ARRAY_A: 0.00433s New ARRAY_A: 0.00317s
Output for 8.0.12
Old ARRAY_N: 0.00685s New ARRAY_N: 0.00570s Old ARRAY_A: 0.00407s New ARRAY_A: 0.00295s
Output for 8.0.11
Old ARRAY_N: 0.00695s New ARRAY_N: 0.00575s Old ARRAY_A: 0.00401s New ARRAY_A: 0.00295s
Output for 8.0.10
Old ARRAY_N: 0.00706s New ARRAY_N: 0.00595s Old ARRAY_A: 0.00414s New ARRAY_A: 0.00298s
Output for 8.0.9
Old ARRAY_N: 0.00747s New ARRAY_N: 0.00600s Old ARRAY_A: 0.00406s New ARRAY_A: 0.00297s
Output for 8.0.8
Old ARRAY_N: 0.00652s New ARRAY_N: 0.00557s Old ARRAY_A: 0.00387s New ARRAY_A: 0.00291s
Output for 8.0.7
Old ARRAY_N: 0.00688s New ARRAY_N: 0.00608s Old ARRAY_A: 0.00412s New ARRAY_A: 0.00293s
Output for 8.0.6
Old ARRAY_N: 0.00686s New ARRAY_N: 0.00586s Old ARRAY_A: 0.00398s New ARRAY_A: 0.00293s
Output for 8.0.5
Old ARRAY_N: 0.00695s New ARRAY_N: 0.00625s Old ARRAY_A: 0.00387s New ARRAY_A: 0.00302s
Output for 8.0.3
Old ARRAY_N: 0.01425s New ARRAY_N: 0.00908s Old ARRAY_A: 0.00447s New ARRAY_A: 0.00319s
Output for 8.0.2
Old ARRAY_N: 0.00686s New ARRAY_N: 0.00580s Old ARRAY_A: 0.00411s New ARRAY_A: 0.00299s
Output for 8.0.1
Old ARRAY_N: 0.00674s New ARRAY_N: 0.00583s Old ARRAY_A: 0.00397s New ARRAY_A: 0.00298s
Output for 7.4.33
Old ARRAY_N: 0.00692s New ARRAY_N: 0.00624s Old ARRAY_A: 0.00426s New ARRAY_A: 0.00336s
Output for 7.4.32
Old ARRAY_N: 0.01276s New ARRAY_N: 0.00837s Old ARRAY_A: 0.00400s New ARRAY_A: 0.00307s
Output for 7.4.30
Old ARRAY_N: 0.00682s New ARRAY_N: 0.00578s Old ARRAY_A: 0.00400s New ARRAY_A: 0.00307s
Output for 7.4.29
Old ARRAY_N: 0.00686s New ARRAY_N: 0.00571s Old ARRAY_A: 0.00396s New ARRAY_A: 0.00317s
Output for 7.4.28
Old ARRAY_N: 0.00690s New ARRAY_N: 0.00593s Old ARRAY_A: 0.00393s New ARRAY_A: 0.00321s
Output for 7.4.27
Old ARRAY_N: 0.00692s New ARRAY_N: 0.00582s Old ARRAY_A: 0.00403s New ARRAY_A: 0.00301s
Output for 7.4.26
Old ARRAY_N: 0.00735s New ARRAY_N: 0.00612s Old ARRAY_A: 0.00402s New ARRAY_A: 0.00300s
Output for 7.4.25
Old ARRAY_N: 0.00665s New ARRAY_N: 0.00569s Old ARRAY_A: 0.00409s New ARRAY_A: 0.00311s
Output for 7.4.24
Old ARRAY_N: 0.00686s New ARRAY_N: 0.00595s Old ARRAY_A: 0.00424s New ARRAY_A: 0.00306s
Output for 7.4.23
Old ARRAY_N: 0.00776s New ARRAY_N: 0.00732s Old ARRAY_A: 0.00401s New ARRAY_A: 0.00305s
Output for 7.4.22
Old ARRAY_N: 0.00687s New ARRAY_N: 0.00586s Old ARRAY_A: 0.00423s New ARRAY_A: 0.00302s
Output for 7.4.21
Old ARRAY_N: 0.00711s New ARRAY_N: 0.00594s Old ARRAY_A: 0.00428s New ARRAY_A: 0.00314s
Output for 7.4.20
Old ARRAY_N: 0.00681s New ARRAY_N: 0.00580s Old ARRAY_A: 0.00424s New ARRAY_A: 0.00314s
Output for 7.4.19
Old ARRAY_N: 0.00686s New ARRAY_N: 0.00586s Old ARRAY_A: 0.00410s New ARRAY_A: 0.00319s
Output for 7.4.18
Old ARRAY_N: 0.00783s New ARRAY_N: 0.00737s Old ARRAY_A: 0.00457s New ARRAY_A: 0.00373s
Output for 7.4.16
Old ARRAY_N: 0.00732s New ARRAY_N: 0.00656s Old ARRAY_A: 0.00428s New ARRAY_A: 0.00324s
Output for 7.4.15
Old ARRAY_N: 0.00797s New ARRAY_N: 0.00666s Old ARRAY_A: 0.00456s New ARRAY_A: 0.00354s
Output for 7.4.14
Old ARRAY_N: 0.00964s New ARRAY_N: 0.00988s Old ARRAY_A: 0.00434s New ARRAY_A: 0.00311s
Output for 7.4.13
Old ARRAY_N: 0.00733s New ARRAY_N: 0.00773s Old ARRAY_A: 0.00571s New ARRAY_A: 0.00367s
Output for 7.4.12
Old ARRAY_N: 0.00887s New ARRAY_N: 0.00746s Old ARRAY_A: 0.00573s New ARRAY_A: 0.00336s
Output for 7.4.11
Old ARRAY_N: 0.00868s New ARRAY_N: 0.00790s Old ARRAY_A: 0.00536s New ARRAY_A: 0.00354s
Output for 7.4.10
Old ARRAY_N: 0.00800s New ARRAY_N: 0.00911s Old ARRAY_A: 0.00498s New ARRAY_A: 0.00371s
Output for 7.4.9
Old ARRAY_N: 0.00839s New ARRAY_N: 0.00649s Old ARRAY_A: 0.00579s New ARRAY_A: 0.00496s
Output for 7.4.8
Old ARRAY_N: 0.00932s New ARRAY_N: 0.00770s Old ARRAY_A: 0.00589s New ARRAY_A: 0.00426s
Output for 7.4.7
Old ARRAY_N: 0.00834s New ARRAY_N: 0.00704s Old ARRAY_A: 0.00469s New ARRAY_A: 0.00460s
Output for 7.4.6
Old ARRAY_N: 0.00769s New ARRAY_N: 0.00722s Old ARRAY_A: 0.00496s New ARRAY_A: 0.00421s
Output for 7.4.5
Old ARRAY_N: 0.00912s New ARRAY_N: 0.00652s Old ARRAY_A: 0.00436s New ARRAY_A: 0.00366s
Output for 7.4.4
Old ARRAY_N: 0.00759s New ARRAY_N: 0.00734s Old ARRAY_A: 0.00468s New ARRAY_A: 0.00341s
Output for 7.4.3
Old ARRAY_N: 0.01141s New ARRAY_N: 0.01088s Old ARRAY_A: 0.00504s New ARRAY_A: 0.00326s
Output for 7.4.2
Old ARRAY_N: 0.00997s New ARRAY_N: 0.00682s Old ARRAY_A: 0.00674s New ARRAY_A: 0.00366s
Output for 7.4.1
Old ARRAY_N: 0.00803s New ARRAY_N: 0.00783s Old ARRAY_A: 0.00524s New ARRAY_A: 0.00461s
Output for 7.4.0
Old ARRAY_N: 0.00993s New ARRAY_N: 0.00718s Old ARRAY_A: 0.00683s New ARRAY_A: 0.00410s

preferences:
113.97 ms | 574 KiB | 5 Q