3v4l.org

run code in 300+ PHP versions simultaneously
<?php $myArray = array( '1' => array ( 'name' => 123, 'id' => 105740727, 'email' => 'fghfhfh', 'phrases_relevant' => 123, 'searches_id' => 105740727, ), '2' => array ( 'name' => 'porshe', 'id' => 105713889, 'email' => 'fghfghf', 'phrases_relevant' => 'porshe', 'searches_id' => 105713889, ), '3' => array ( 'name' => 'porshe', 'id' => 105713889, 'email' => 'fghfghf', 'phrases_relevant' => 'merce', 'searches_id' => 105713889, ), ); function sortByOrder($a, $b) { return $a['searches_id'] - $b['searches_id']; } usort($myArray, 'sortByOrder'); foreach ($myArray as $key => $value) { if (empty($temp) || $temp != $value['searches_id']) { $temp = $value['searches_id']; } $result[$value['searches_id']]['email'] = $value['email']; $result[$value['searches_id']]['projects'][] = $value['phrases_relevant']; } $result = array_values($result); print_r($result);die;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 28
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 28
Branch analysis from position: 7
2 jumps found. (Code = 47) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 16
Branch analysis from position: 13
Branch analysis from position: 28
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 28
filename:       /in/J7eGX
function name:  (null)
number of ops:  38
compiled vars:  !0 = $myArray, !1 = $value, !2 = $key, !3 = $temp, !4 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   35     1        INIT_FCALL                                               'usort'
          2        SEND_REF                                                 !0
          3        SEND_VAL                                                 'sortByOrder'
          4        DO_ICALL                                                 
   36     5      > FE_RESET_R                                       $7      !0, ->28
          6    > > FE_FETCH_R                                       ~8      $7, !1, ->28
          7    >   ASSIGN                                                   !2, ~8
   37     8        ISSET_ISEMPTY_CV                                 ~10     !3
          9      > JMPNZ_EX                                         ~10     ~10, ->13
         10    >   FETCH_DIM_R                                      ~11     !1, 'searches_id'
         11        IS_NOT_EQUAL                                     ~12     !3, ~11
         12        BOOL                                             ~10     ~12
         13    > > JMPZ                                                     ~10, ->16
   38    14    >   FETCH_DIM_R                                      ~13     !1, 'searches_id'
         15        ASSIGN                                                   !3, ~13
   40    16    >   FETCH_DIM_R                                      ~15     !1, 'searches_id'
         17        FETCH_DIM_R                                      ~18     !1, 'email'
         18        FETCH_DIM_W                                      $16     !4, ~15
         19        ASSIGN_DIM                                               $16, 'email'
         20        OP_DATA                                                  ~18
   41    21        FETCH_DIM_R                                      ~19     !1, 'searches_id'
         22        FETCH_DIM_R                                      ~23     !1, 'phrases_relevant'
         23        FETCH_DIM_W                                      $20     !4, ~19
         24        FETCH_DIM_W                                      $21     $20, 'projects'
         25        ASSIGN_DIM                                               $21
         26        OP_DATA                                                  ~23
   36    27      > JMP                                                      ->6
         28    >   FE_FREE                                                  $7
   43    29        INIT_FCALL                                               'array_values'
         30        SEND_VAR                                                 !4
         31        DO_ICALL                                         $24     
         32        ASSIGN                                                   !4, $24
   45    33        INIT_FCALL                                               'print_r'
         34        SEND_VAR                                                 !4
         35        DO_ICALL                                                 
         36      > EXIT                                                     
   46    37*     > RETURN                                                   1

Function sortbyorder:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/J7eGX
function name:  sortByOrder
number of ops:  7
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   33     2        FETCH_DIM_R                                      ~2      !0, 'searches_id'
          3        FETCH_DIM_R                                      ~3      !1, 'searches_id'
          4        SUB                                              ~4      ~2, ~3
          5      > RETURN                                                   ~4
   34     6*     > RETURN                                                   null

End of function sortbyorder

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.06 ms | 1017 KiB | 16 Q