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); var_dump($count1); var_dump($count2); 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 = 32, Position 2 = 45
Branch analysis from position: 32
2 jumps found. (Code = 77) Position 1 = 33, Position 2 = 44
Branch analysis from position: 33
2 jumps found. (Code = 78) Position 1 = 34, Position 2 = 44
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 43
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
Branch analysis from position: 43
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
Branch analysis from position: 45
filename:       /in/YSoIH
function name:  (null)
number of ops:  46
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
   22    14        INIT_FCALL                                               'counthashes'
         15        SEND_VAR                                                 !2
         16        DO_FCALL                                      0  $18     
         17        ASSIGN                                                   !4, $18
   23    18        INIT_FCALL                                               'counthashes'
         19        SEND_VAR                                                 !3
         20        DO_FCALL                                      0  $20     
         21        ASSIGN                                                   !5, $20
   25    22        INIT_FCALL                                               'var_dump'
         23        SEND_VAR                                                 !4
         24        DO_ICALL                                                 
   26    25        INIT_FCALL                                               'var_dump'
         26        SEND_VAR                                                 !5
         27        DO_ICALL                                                 
   28    28        COUNT                                            ~24     !4
         29        COUNT                                            ~25     !5
         30        IS_IDENTICAL                                             ~24, ~25
         31      > JMPZ                                                     ~26, ->45
   29    32    > > FE_RESET_R                                       $27     !4, ->44
         33    > > FE_FETCH_R                                       ~28     $27, !6, ->44
         34    >   ASSIGN                                                   !7, ~28
   30    35        CONCAT                                           ~30     !7, '+and+'
         36        CONCAT                                           ~31     ~30, !6
         37        CONCAT                                           ~32     ~31, '%0A'
         38        ECHO                                                     ~32
   31    39        FETCH_DIM_R                                      ~33     !5, !7
         40        IS_NOT_IDENTICAL                                         !6, ~33
         41      > JMPZ                                                     ~34, ->43
   32    42    >   ECHO                                                     'not+the+same%21'
   29    43    > > JMP                                                      ->33
         44    >   FE_FREE                                                  $27
   35    45    > > 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/YSoIH
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, ->16
          3    > > FE_FETCH_R                                               $5, !2, ->16
   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
   16    13    >   FETCH_DIM_RW                                     $11     !1, !3
         14        PRE_INC                                                  $11
   11    15      > JMP                                                      ->3
         16    >   FE_FREE                                                  $5
   19    17      > RETURN                                                   !1
   20    18*     > RETURN                                                   null

End of function counthashes

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.37 ms | 1403 KiB | 19 Q