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);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/a9X1n
function name:  (null)
number of ops:  29
compiled vars:  !0 = $a, !1 = $b, !2 = $array1, !3 = $array2, !4 = $count1, !5 = $count2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $6      'StdClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $6
    4     3        NEW                                              $9      'StdClass'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $9
    5     6        INIT_ARRAY                                       ~12     !0
          7        ADD_ARRAY_ELEMENT                                ~12     !0
          8        ADD_ARRAY_ELEMENT                                ~12     !1
          9        ASSIGN                                                   !2, ~12
    6    10        INIT_ARRAY                                       ~14     !0
         11        ADD_ARRAY_ELEMENT                                ~14     !1
         12        ADD_ARRAY_ELEMENT                                ~14     !1
         13        ASSIGN                                                   !3, ~14
   23    14        INIT_FCALL                                               'counthashes'
         15        SEND_VAR                                                 !2
         16        DO_FCALL                                      0  $16     
         17        ASSIGN                                                   !4, $16
   24    18        INIT_FCALL                                               'counthashes'
         19        SEND_VAR                                                 !3
         20        DO_FCALL                                      0  $18     
         21        ASSIGN                                                   !5, $18
   26    22        INIT_FCALL                                               'var_dump'
         23        SEND_VAR                                                 !4
         24        DO_ICALL                                                 
   28    25        INIT_FCALL                                               'var_dump'
         26        SEND_VAR                                                 !5
         27        DO_ICALL                                                 
         28      > 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/a9X1n
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:
154.92 ms | 1403 KiB | 19 Q