3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = new StdClass(); $b = new StdClass(); $array1 = array($a, $a, $b); $array2 = array($a, $b, $b); 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; }; $count1 = countHashes($array1); $count2 = countHashes($array2); if (count($count1) === count($count2)) { foreach ($count1 as $key => $value) { echo $key . " and " . $value . "\n"; if ($count2[$key] !== $value) { echo 'not the same!'; } } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 39
Branch analysis from position: 26
2 jumps found. (Code = 77) Position 1 = 27, Position 2 = 38
Branch analysis from position: 27
2 jumps found. (Code = 78) Position 1 = 28, Position 2 = 38
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 37
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Branch analysis from position: 37
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
Branch analysis from position: 39
filename:       /in/3VSni
function name:  (null)
number of ops:  40
compiled vars:  !0 = $a, !1 = $b, !2 = $array1, !3 = $array2, !4 = $count1, !5 = $count2, !6 = $value, !7 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $8      'StdClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $8
    4     3        NEW                                              $11     'StdClass'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $11
    5     6        INIT_ARRAY                                       ~14     !0
          7        ADD_ARRAY_ELEMENT                                ~14     !0
          8        ADD_ARRAY_ELEMENT                                ~14     !1
          9        ASSIGN                                                   !2, ~14
    6    10        INIT_ARRAY                                       ~16     !0
         11        ADD_ARRAY_ELEMENT                                ~16     !1
         12        ADD_ARRAY_ELEMENT                                ~16     !1
         13        ASSIGN                                                   !3, ~16
   23    14        INIT_FCALL                                               'counthashes'
         15        SEND_VAR                                                 !2
         16        DO_FCALL                                      0  $18     
         17        ASSIGN                                                   !4, $18
   24    18        INIT_FCALL                                               'counthashes'
         19        SEND_VAR                                                 !3
         20        DO_FCALL                                      0  $20     
         21        ASSIGN                                                   !5, $20
   26    22        COUNT                                            ~22     !4
         23        COUNT                                            ~23     !5
         24        IS_IDENTICAL                                             ~22, ~23
         25      > JMPZ                                                     ~24, ->39
   27    26    > > FE_RESET_R                                       $25     !4, ->38
         27    > > FE_FETCH_R                                       ~26     $25, !6, ->38
         28    >   ASSIGN                                                   !7, ~26
   28    29        CONCAT                                           ~28     !7, '+and+'
         30        CONCAT                                           ~29     ~28, !6
         31        CONCAT                                           ~30     ~29, '%0A'
         32        ECHO                                                     ~30
   29    33        FETCH_DIM_R                                      ~31     !5, !7
         34        IS_NOT_IDENTICAL                                         !6, ~31
         35      > JMPZ                                                     ~32, ->37
   30    36    >   ECHO                                                     'not+the+same%21'
   27    37    > > JMP                                                      ->27
         38    >   FE_FREE                                                  $25
   33    39    > > RETURN                                                   1

Function counthashes:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 14
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 14
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: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/3VSni
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
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        ASSIGN                                                   !1, <array>
   11     2      > FE_RESET_R                                       $5      !0, ->14
          3    > > FE_FETCH_R                                               $5, !2, ->14
   12     4    >   INIT_FCALL                                               'spl_object_hash'
          5        SEND_VAR                                                 !2
          6        DO_ICALL                                         $6      
          7        ASSIGN                                                   !3, $6
   13     8        ISSET_ISEMPTY_DIM_OBJ                         0  ~8      !1, !3
          9        BOOL_NOT                                         ~9      ~8
         10      > JMPZ                                                     ~9, ->13
   14    11    >   ASSIGN_DIM                                               !1, !3
         12        OP_DATA                                                  0
   11    13    > > JMP                                                      ->3
         14    >   FE_FREE                                                  $5
   18    15        FETCH_DIM_RW                                     $11     !1, !3
         16        PRE_INC                                                  $11
   20    17      > RETURN                                                   !1
   21    18*     > RETURN                                                   null

End of function counthashes

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.58 ms | 1403 KiB | 17 Q