3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr=Array(Array("segments" => Array(1=>"Gcia de Auditoría Interna",0 => "Auditoria Interna 1"),"groups" => Array("estados" => "sp","cidade" => "sumpaulo")), Array("segments" => Array(2 => "Gerencia Recursos Humanos",1 => "Gcia Dpto Admin de Pers. y Rel. Laboral",0 => "SubGcia Administración de Personal"),"groups" => Array("estados" => "sp","cidade" => "")), Array("segments" => Array(2 => "Gerencia Recursos Humanos",1 => "Gcia Dpto Admin de Pers. y Rel. Laboral",0 => "SubGcia Administración de Personal"),"groups" => Array("estados" => "sp","cidade" => ""))); usort($arr,function($a,$b){ return strcmp(json_encode($a),json_encode($b)); }); $rst=array(); $cache=array(); while($p=array_shift($arr)) { if(empty($cache)) { $cache[]=$p; } elseif($cache[0]==$p) { $cache[]=$p; } else { $rst[]=array_merge($cache[0],array("total"=>count($cache))); $cache=array(); $cache[]=$p; } } if(!empty($cache)) { $rst[]=array_merge($cache[0],array("total"=>count($cache))); } print_r($rst);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 9
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 49
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 49
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 20
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 9
Branch analysis from position: 37
Branch analysis from position: 9
filename:       /in/j5Rgi
function name:  (null)
number of ops:  53
compiled vars:  !0 = $arr, !1 = $rst, !2 = $cache, !3 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    3     1        INIT_FCALL                                               'usort'
          2        SEND_REF                                                 !0
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fj5Rgi%3A3%240'
    5     4        SEND_VAL                                                 ~5
          5        DO_ICALL                                                 
    6     6        ASSIGN                                                   !1, <array>
    7     7        ASSIGN                                                   !2, <array>
    8     8      > JMP                                                      ->32
   10     9    >   ISSET_ISEMPTY_CV                                         !2
         10      > JMPZ                                                     ~9, ->14
   12    11    >   ASSIGN_DIM                                               !2
         12        OP_DATA                                                  !3
         13      > JMP                                                      ->32
   14    14    >   FETCH_DIM_R                                      ~11     !2, 0
         15        IS_EQUAL                                                 !3, ~11
         16      > JMPZ                                                     ~12, ->20
   16    17    >   ASSIGN_DIM                                               !2
         18        OP_DATA                                                  !3
         19      > JMP                                                      ->32
   20    20    >   INIT_FCALL                                               'array_merge'
         21        FETCH_DIM_R                                      ~15     !2, 0
         22        SEND_VAL                                                 ~15
         23        COUNT                                            ~16     !2
         24        INIT_ARRAY                                       ~17     ~16, 'total'
         25        SEND_VAL                                                 ~17
         26        DO_ICALL                                         $18     
         27        ASSIGN_DIM                                               !1
         28        OP_DATA                                                  $18
   21    29        ASSIGN                                                   !2, <array>
   22    30        ASSIGN_DIM                                               !2
         31        OP_DATA                                                  !3
    8    32    >   INIT_FCALL                                               'array_shift'
         33        SEND_REF                                                 !0
         34        DO_ICALL                                         $21     
         35        ASSIGN                                           ~22     !3, $21
         36      > JMPNZ                                                    ~22, ->9
   25    37    >   ISSET_ISEMPTY_CV                                 ~23     !2
         38        BOOL_NOT                                         ~24     ~23
         39      > JMPZ                                                     ~24, ->49
   27    40    >   INIT_FCALL                                               'array_merge'
         41        FETCH_DIM_R                                      ~26     !2, 0
         42        SEND_VAL                                                 ~26
         43        COUNT                                            ~27     !2
         44        INIT_ARRAY                                       ~28     ~27, 'total'
         45        SEND_VAL                                                 ~28
         46        DO_ICALL                                         $29     
         47        ASSIGN_DIM                                               !1
         48        OP_DATA                                                  $29
   29    49    >   INIT_FCALL                                               'print_r'
         50        SEND_VAR                                                 !1
         51        DO_ICALL                                                 
         52      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Fj5Rgi%3A3%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/j5Rgi
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        INIT_FCALL                                               'strcmp'
          3        INIT_FCALL                                               'json_encode'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $2      
          6        SEND_VAR                                                 $2
          7        INIT_FCALL                                               'json_encode'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                         $3      
         10        SEND_VAR                                                 $3
         11        DO_ICALL                                         $4      
         12      > RETURN                                                   $4
    5    13*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fj5Rgi%3A3%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.88 ms | 1400 KiB | 25 Q