3v4l.org

run code in 300+ PHP versions simultaneously
<?php $infoArray =array( array( 'season'=>'winter 2014', 'link'=>'link1' ), array( 'season'=>'summer 2013', 'link'=>'link2' ), array( 'season'=>'fall 2012', 'link'=>'link3' ), array( 'season'=>'summer 2014', 'link'=>'link4' ), array( 'season'=>'winter 2013', 'link'=>'link5' ) ); $newArray =array(); $innerArray=array(); foreach ($infoArray as $info){ $season = explode(" ", $info['season']); $seasonName = $season[0]; $seasonYear = $season[1]; if (array_key_exists($seasonYear, $newArray)) { $newArray[$seasonYear][$seasonName]=$info['link'] ; } else { $innerArray[$seasonName] = $info['link']; $newArray[$seasonYear]=$innerArray ; } } var_dump($newArray);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 28
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 28
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 22
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/Auqms
function name:  (null)
number of ops:  33
compiled vars:  !0 = $infoArray, !1 = $newArray, !2 = $innerArray, !3 = $info, !4 = $season, !5 = $seasonName, !6 = $seasonYear
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   26     1        ASSIGN                                                   !1, <array>
   27     2        ASSIGN                                                   !2, <array>
   29     3      > FE_RESET_R                                       $10     !0, ->28
          4    > > FE_FETCH_R                                               $10, !3, ->28
   30     5    >   INIT_FCALL                                               'explode'
          6        SEND_VAL                                                 '+'
          7        FETCH_DIM_R                                      ~11     !3, 'season'
          8        SEND_VAL                                                 ~11
          9        DO_ICALL                                         $12     
         10        ASSIGN                                                   !4, $12
   31    11        FETCH_DIM_R                                      ~14     !4, 0
         12        ASSIGN                                                   !5, ~14
   32    13        FETCH_DIM_R                                      ~16     !4, 1
         14        ASSIGN                                                   !6, ~16
   35    15        ARRAY_KEY_EXISTS                                         !6, !1
         16      > JMPZ                                                     ~18, ->22
   36    17    >   FETCH_DIM_R                                      ~21     !3, 'link'
         18        FETCH_DIM_W                                      $19     !1, !6
         19        ASSIGN_DIM                                               $19, !5
         20        OP_DATA                                                  ~21
         21      > JMP                                                      ->27
   39    22    >   FETCH_DIM_R                                      ~23     !3, 'link'
         23        ASSIGN_DIM                                               !2, !5
         24        OP_DATA                                                  ~23
   40    25        ASSIGN_DIM                                               !1, !6
         26        OP_DATA                                                  !2
   29    27    > > JMP                                                      ->4
         28    >   FE_FREE                                                  $10
   45    29        INIT_FCALL                                               'var_dump'
         30        SEND_VAR                                                 !1
         31        DO_ICALL                                                 
         32      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.76 ms | 1396 KiB | 17 Q