3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = 'Spider-man|Spider-man 2|Spider-man 3|Apple|Google|Banana|Citrus'; $result = array(); foreach(explode('|', $string) as $item) { $firstLetter = $item[0]; if(!isset($result[$firstLetter])) { $result[$firstLetter] = array(); } $result[$firstLetter][] = $item; } ksort($result); var_dump($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 19
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 19
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 15
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/e5KEH
function name:  (null)
number of ops:  27
compiled vars:  !0 = $string, !1 = $result, !2 = $item, !3 = $firstLetter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'Spider-man%7CSpider-man+2%7CSpider-man+3%7CApple%7CGoogle%7CBanana%7CCitrus'
    4     1        ASSIGN                                                   !1, <array>
    5     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '%7C'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $6      
          6      > FE_RESET_R                                       $7      $6, ->19
          7    > > FE_FETCH_R                                               $7, !2, ->19
    6     8    >   FETCH_DIM_R                                      ~8      !2, 0
          9        ASSIGN                                                   !3, ~8
    7    10        ISSET_ISEMPTY_DIM_OBJ                         0  ~10     !1, !3
         11        BOOL_NOT                                         ~11     ~10
         12      > JMPZ                                                     ~11, ->15
    8    13    >   ASSIGN_DIM                                               !1, !3
         14        OP_DATA                                                  <array>
   10    15    >   FETCH_DIM_W                                      $13     !1, !3
         16        ASSIGN_DIM                                               $13
         17        OP_DATA                                                  !2
    5    18      > JMP                                                      ->7
         19    >   FE_FREE                                                  $7
   13    20        INIT_FCALL                                               'ksort'
         21        SEND_REF                                                 !1
         22        DO_ICALL                                                 
   14    23        INIT_FCALL                                               'var_dump'
         24        SEND_VAR                                                 !1
         25        DO_ICALL                                                 
         26      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.02 ms | 1396 KiB | 19 Q