3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = array( array( 'keywordid' => 98, 'keyword' => 'sample keyword 34', 'type' => 'NATURAL', 'longname' => 'UK' ), array( 'keywordid' => 99, 'keyword' => 'sample keyword 35', 'type' => 'NATURAL', 'longname' => 'UK' ), array( 'keywordid' => 100, 'keyword' => 'sample keyword 36', 'type' => 'NATURAL', 'longname' => 'UK' ), array( 'keywordid' => 97, 'keyword' => 'sample keyword 37', 'type' => 'NATURAL', 'longname' => 'UK' ), array( 'keywordid' => 96, 'keyword' => 'sample keyword 38', 'type' => 'NATURAL', 'longname' => 'UK' ), array( 'keywordid' => 95, 'keyword' => 'sample keyword 39', 'type' => 'NATURAL', 'longname' => 'UK' ), array( 'keywordid' => 94, 'keyword' => 'sample keyword 40', 'type' => 'NATURAL', 'longname' => 'UK' ), array( 'keywordid' => 93, 'keyword' => 'sample keyword 41', 'type' => 'NATURAL', 'longname' => 'UK' ), array( 'keywordid' => 92, 'keyword' => 'sample keyword 42', 'type' => 'NATURAL', 'longname' => 'UK' ), array( 'keywordid' => 91, 'keyword' => 'sample keyword 43', 'type' => 'NATURAL', 'longname' => 'UK' ) ); $order = array(100, 91, 95); $order = array_flip($order); $noMatchBucket = count($order); $temp = array_fill(0, $noMatchBucket + 1, array()); foreach ($data as $item) { $bucket = isset($order[$item['keywordid']]) ? $order[$item['keywordid']] : $noMatchBucket; $temp[$bucket][] = $item; } $data = array(); foreach ($temp as $bucket) { $data = array_merge($data, $bucket); } print_r($data);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 30
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 30
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 24
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 30
2 jumps found. (Code = 77) Position 1 = 33, Position 2 = 40
Branch analysis from position: 33
2 jumps found. (Code = 78) Position 1 = 34, Position 2 = 40
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
Branch analysis from position: 30
filename:       /in/Qku9H
function name:  (null)
number of ops:  45
compiled vars:  !0 = $data, !1 = $order, !2 = $noMatchBucket, !3 = $temp, !4 = $item, !5 = $bucket
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   66     1        ASSIGN                                                   !1, <array>
   68     2        INIT_FCALL                                               'array_flip'
          3        SEND_VAR                                                 !1
          4        DO_ICALL                                         $8      
          5        ASSIGN                                                   !1, $8
   69     6        COUNT                                            ~10     !1
          7        ASSIGN                                                   !2, ~10
   70     8        INIT_FCALL                                               'array_fill'
          9        SEND_VAL                                                 0
         10        ADD                                              ~12     !2, 1
         11        SEND_VAL                                                 ~12
         12        SEND_VAL                                                 <array>
         13        DO_ICALL                                         $13     
         14        ASSIGN                                                   !3, $13
   72    15      > FE_RESET_R                                       $15     !0, ->30
         16    > > FE_FETCH_R                                               $15, !4, ->30
   73    17    >   FETCH_DIM_R                                      ~16     !4, 'keywordid'
         18        ISSET_ISEMPTY_DIM_OBJ                         0          !1, ~16
         19      > JMPZ                                                     ~17, ->24
         20    >   FETCH_DIM_R                                      ~18     !4, 'keywordid'
         21        FETCH_DIM_R                                      ~19     !1, ~18
         22        QM_ASSIGN                                        ~20     ~19
         23      > JMP                                                      ->25
         24    >   QM_ASSIGN                                        ~20     !2
         25    >   ASSIGN                                                   !5, ~20
   74    26        FETCH_DIM_W                                      $22     !3, !5
         27        ASSIGN_DIM                                               $22
         28        OP_DATA                                                  !4
   72    29      > JMP                                                      ->16
         30    >   FE_FREE                                                  $15
   77    31        ASSIGN                                                   !0, <array>
   78    32      > FE_RESET_R                                       $25     !3, ->40
         33    > > FE_FETCH_R                                               $25, !5, ->40
   79    34    >   INIT_FCALL                                               'array_merge'
         35        SEND_VAR                                                 !0
         36        SEND_VAR                                                 !5
         37        DO_ICALL                                         $26     
         38        ASSIGN                                                   !0, $26
   78    39      > JMP                                                      ->33
         40    >   FE_FREE                                                  $25
   82    41        INIT_FCALL                                               'print_r'
         42        SEND_VAR                                                 !0
         43        DO_ICALL                                                 
         44      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.57 ms | 1467 KiB | 17 Q