3v4l.org

run code in 300+ PHP versions simultaneously
<?php function hasort($arr) { $a = $b = array(); foreach($arr as $v => $k) $a[$k][] = $v; ksort($a); foreach($a as $v => $i) foreach($i as $k) $b[$k] = $v; return $b; } $a = array('a' => 10, 'z' => 10, 'c' => 10, 'b' => 11, 'd' => 10); $a = hasort($a); print_r($a); echo '<pre>'; echo json_encode($a); echo '</pre>';
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qsiNT
function name:  (null)
number of ops:  15
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   ASSIGN                                                   !0, <array>
   11     1        INIT_FCALL                                               'hasort'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $2      
          4        ASSIGN                                                   !0, $2
   12     5        INIT_FCALL                                               'print_r'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                                 
   13     8        ECHO                                                     '%3Cpre%3E'
   14     9        INIT_FCALL                                               'json_encode'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $5      
         12        ECHO                                                     $5
   15    13        ECHO                                                     '%3C%2Fpre%3E'
         14      > RETURN                                                   1

Function hasort:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 10
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 24
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 24
Branch analysis from position: 16
2 jumps found. (Code = 77) Position 1 = 18, Position 2 = 22
Branch analysis from position: 18
2 jumps found. (Code = 78) Position 1 = 19, Position 2 = 22
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 22
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
Branch analysis from position: 10
filename:       /in/qsiNT
function name:  hasort
number of ops:  27
compiled vars:  !0 = $arr, !1 = $a, !2 = $b, !3 = $k, !4 = $v, !5 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        ASSIGN                                           ~6      !2, <array>
          2        ASSIGN                                                   !1, ~6
    4     3      > FE_RESET_R                                       $8      !0, ->10
          4    > > FE_FETCH_R                                       ~9      $8, !3, ->10
          5    >   ASSIGN                                                   !4, ~9
          6        FETCH_DIM_W                                      $11     !1, !3
          7        ASSIGN_DIM                                               $11
          8        OP_DATA                                                  !4
          9      > JMP                                                      ->4
         10    >   FE_FREE                                                  $8
    5    11        INIT_FCALL                                               'ksort'
         12        SEND_REF                                                 !1
         13        DO_ICALL                                                 
    6    14      > FE_RESET_R                                       $14     !1, ->24
         15    > > FE_FETCH_R                                       ~15     $14, !5, ->24
         16    >   ASSIGN                                                   !4, ~15
    7    17      > FE_RESET_R                                       $17     !5, ->22
         18    > > FE_FETCH_R                                               $17, !3, ->22
         19    >   ASSIGN_DIM                                               !2, !3
         20        OP_DATA                                                  !4
         21      > JMP                                                      ->18
         22    >   FE_FREE                                                  $17
    6    23      > JMP                                                      ->15
         24    >   FE_FREE                                                  $14
    8    25      > RETURN                                                   !2
    9    26*     > RETURN                                                   null

End of function hasort

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
201.88 ms | 1394 KiB | 20 Q