3v4l.org

run code in 300+ PHP versions simultaneously
<?php function countHashes ($array) { $count = array(); foreach ($array as $val) { $hash = spl_object_hash($val); if (! isset($count[$hash])) { $count[$hash] = 0; } $count[$hash]++; } return $count; }; function checkWhetherSame($array1, $array2) { $count1 = countHashes($array1); $count2 = countHashes($array2); if (count($count1) === count($count2)) { foreach ($count1 as $key => $value) { if ($count2[$key] !== $value) { return false; } } } return true; }; $a = new StdClass(); $b = new StdClass(); $array1 = array($a, $a, $b); $array2 = array($a, $b, $b); var_dump(checkWhetherSame($array1, $array2));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/T5qo7
function name:  (null)
number of ops:  22
compiled vars:  !0 = $a, !1 = $b, !2 = $array1, !3 = $array2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   NEW                                              $4      'StdClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $4
   35     3        NEW                                              $7      'StdClass'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $7
   36     6        INIT_ARRAY                                       ~10     !0
          7        ADD_ARRAY_ELEMENT                                ~10     !0
          8        ADD_ARRAY_ELEMENT                                ~10     !1
          9        ASSIGN                                                   !2, ~10
   37    10        INIT_ARRAY                                       ~12     !0
         11        ADD_ARRAY_ELEMENT                                ~12     !1
         12        ADD_ARRAY_ELEMENT                                ~12     !1
         13        ASSIGN                                                   !3, ~12
   39    14        INIT_FCALL                                               'var_dump'
         15        INIT_FCALL                                               'checkwhethersame'
         16        SEND_VAR                                                 !2
         17        SEND_VAR                                                 !3
         18        DO_FCALL                                      0  $14     
         19        SEND_VAR                                                 $14
         20        DO_ICALL                                                 
         21      > RETURN                                                   1

Function counthashes:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 16
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 16
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 13
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/T5qo7
function name:  countHashes
number of ops:  19
compiled vars:  !0 = $array, !1 = $count, !2 = $val, !3 = $hash
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        ASSIGN                                                   !1, <array>
    6     2      > FE_RESET_R                                       $5      !0, ->16
          3    > > FE_FETCH_R                                               $5, !2, ->16
    7     4    >   INIT_FCALL                                               'spl_object_hash'
          5        SEND_VAR                                                 !2
          6        DO_ICALL                                         $6      
          7        ASSIGN                                                   !3, $6
    8     8        ISSET_ISEMPTY_DIM_OBJ                         0  ~8      !1, !3
          9        BOOL_NOT                                         ~9      ~8
         10      > JMPZ                                                     ~9, ->13
    9    11    >   ASSIGN_DIM                                               !1, !3
         12        OP_DATA                                                  0
   11    13    >   FETCH_DIM_RW                                     $11     !1, !3
         14        PRE_INC                                                  $11
    6    15      > JMP                                                      ->3
         16    >   FE_FREE                                                  $5
   14    17      > RETURN                                                   !1
   15    18*     > RETURN                                                   null

End of function counthashes

Function checkwhethersame:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 24
Branch analysis from position: 14
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 23
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 23
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
Branch analysis from position: 24
filename:       /in/T5qo7
function name:  checkWhetherSame
number of ops:  26
compiled vars:  !0 = $array1, !1 = $array2, !2 = $count1, !3 = $count2, !4 = $value, !5 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   19     2        INIT_FCALL                                               'counthashes'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $6      
          5        ASSIGN                                                   !2, $6
   20     6        INIT_FCALL                                               'counthashes'
          7        SEND_VAR                                                 !1
          8        DO_FCALL                                      0  $8      
          9        ASSIGN                                                   !3, $8
   22    10        COUNT                                            ~10     !2
         11        COUNT                                            ~11     !3
         12        IS_IDENTICAL                                             ~10, ~11
         13      > JMPZ                                                     ~12, ->24
   23    14    > > FE_RESET_R                                       $13     !2, ->23
         15    > > FE_FETCH_R                                       ~14     $13, !4, ->23
         16    >   ASSIGN                                                   !5, ~14
   24    17        FETCH_DIM_R                                      ~16     !3, !5
         18        IS_NOT_IDENTICAL                                         !4, ~16
         19      > JMPZ                                                     ~17, ->22
   25    20    >   FE_FREE                                                  $13
         21      > RETURN                                                   <false>
   23    22    > > JMP                                                      ->15
         23    >   FE_FREE                                                  $13
   30    24    > > RETURN                                                   <true>
   31    25*     > RETURN                                                   null

End of function checkwhethersame

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.09 ms | 1402 KiB | 20 Q