3v4l.org

run code in 300+ PHP versions simultaneously
<?php $txt = "3000,MELBOURNE 3001,MELBOURNE 3002,EAST MELBOURNE 3003,WEST MELBOURNE 3603,WEST SYDNEY 3103,NORTH PERTH"; $rows = explode(PHP_EOL, $txt); $arr= []; foreach($rows as $row){ List($postcode, $suburb) = explode(",", $row); If(in_array(substr($suburb,0,4), array("EAST", "WEST")) || in_array(substr($suburb,0,5), array("SOUTH", "NORTH"))){ $temp = explode(" ", $suburb); $arr[$temp[1]][$temp[0]][] = $postcode; }else{ $arr[$suburb][] = $postcode; } } Var_dump($arr);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 49
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 49
Branch analysis from position: 9
2 jumps found. (Code = 47) Position 1 = 25, Position 2 = 32
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 45
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 32
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 49
filename:       /in/RXgSR
function name:  (null)
number of ops:  54
compiled vars:  !0 = $txt, !1 = $rows, !2 = $arr, !3 = $row, !4 = $postcode, !5 = $suburb, !6 = $temp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '3000%2CMELBOURNE%0A3001%2CMELBOURNE%0A3002%2CEAST+MELBOURNE%0A3003%2CWEST+MELBOURNE%0A3603%2CWEST+SYDNEY%0A3103%2CNORTH+PERTH'
   10     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%0A'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $8      
          5        ASSIGN                                                   !1, $8
   11     6        ASSIGN                                                   !2, <array>
   13     7      > FE_RESET_R                                       $11     !1, ->49
          8    > > FE_FETCH_R                                               $11, !3, ->49
   14     9    >   INIT_FCALL                                               'explode'
         10        SEND_VAL                                                 '%2C'
         11        SEND_VAR                                                 !3
         12        DO_ICALL                                         $12     
         13        FETCH_LIST_R                                     $13     $12, 0
         14        ASSIGN                                                   !4, $13
         15        FETCH_LIST_R                                     $15     $12, 1
         16        ASSIGN                                                   !5, $15
         17        FREE                                                     $12
   15    18        INIT_FCALL                                               'substr'
         19        SEND_VAR                                                 !5
         20        SEND_VAL                                                 0
         21        SEND_VAL                                                 4
         22        DO_ICALL                                         $17     
         23        IN_ARRAY                                         ~18     $17, <array>
         24      > JMPNZ_EX                                         ~18     ~18, ->32
         25    >   INIT_FCALL                                               'substr'
         26        SEND_VAR                                                 !5
         27        SEND_VAL                                                 0
         28        SEND_VAL                                                 5
         29        DO_ICALL                                         $19     
         30        IN_ARRAY                                         ~20     $19, <array>
         31        BOOL                                             ~18     ~20
         32    > > JMPZ                                                     ~18, ->45
   16    33    >   INIT_FCALL                                               'explode'
         34        SEND_VAL                                                 '+'
         35        SEND_VAR                                                 !5
         36        DO_ICALL                                         $21     
         37        ASSIGN                                                   !6, $21
   17    38        FETCH_DIM_R                                      ~23     !6, 1
         39        FETCH_DIM_R                                      ~25     !6, 0
         40        FETCH_DIM_W                                      $24     !2, ~23
         41        FETCH_DIM_W                                      $26     $24, ~25
         42        ASSIGN_DIM                                               $26
         43        OP_DATA                                                  !4
         44      > JMP                                                      ->48
   19    45    >   FETCH_DIM_W                                      $28     !2, !5
         46        ASSIGN_DIM                                               $28
         47        OP_DATA                                                  !4
   13    48    > > JMP                                                      ->8
         49    >   FE_FREE                                                  $11
   26    50        INIT_FCALL                                               'var_dump'
         51        SEND_VAR                                                 !2
         52        DO_ICALL                                                 
         53      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.45 ms | 1405 KiB | 19 Q