3v4l.org

run code in 300+ PHP versions simultaneously
<?php $myArray = array('x'=>'europe','y'=>'europe','a'=>'USA','b'=>'USA','c'=>'Canada'); $newList = array(); foreach($myArray as $key => $value){ if(array_key_exists($value, $newList)) array_push($newList[$value], $key); else $newList[$value][] = $key; } print_r($newList);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 17
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 17
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 13
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/WJ3rm
function name:  (null)
number of ops:  22
compiled vars:  !0 = $myArray, !1 = $newList, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    6     2      > FE_RESET_R                                       $6      !0, ->17
          3    > > FE_FETCH_R                                       ~7      $6, !2, ->17
          4    >   ASSIGN                                                   !3, ~7
    7     5        ARRAY_KEY_EXISTS                                         !2, !1
          6      > JMPZ                                                     ~9, ->13
    8     7    >   INIT_FCALL                                               'array_push'
          8        FETCH_DIM_W                                      $10     !1, !2
          9        SEND_REF                                                 $10
         10        SEND_VAR                                                 !3
         11        DO_ICALL                                                 
    7    12      > JMP                                                      ->16
   10    13    >   FETCH_DIM_W                                      $12     !1, !2
         14        ASSIGN_DIM                                               $12
         15        OP_DATA                                                  !3
    6    16    > > JMP                                                      ->3
         17    >   FE_FREE                                                  $6
   12    18        INIT_FCALL                                               'print_r'
         19        SEND_VAR                                                 !1
         20        DO_ICALL                                                 
         21      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.42 ms | 1011 KiB | 15 Q