3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ [ 'id' => 1, 'email_id' => 'ok@gmail.com', 'password' => 'test' ], [ 'id' => 2, 'email_id' => 'check@gmail.com', 'password' => 'test' ], [ 'id' => 3, 'email_id' => 'an@gmail.com', 'password' => 'pass' ] ]; $result = []; foreach ($array as $row) { if (!isset($result[$row['password']])) { $result[$row['password']] = $row; } else { if (isset($result[$row['password']]['id'])) { $result[$row['password']] = [$result[$row['password']]]; } $result[$row['password']][] = $row; } } var_export(array_values($result));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 27
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 27
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 12
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 22
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 22
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/teeIa
function name:  (null)
number of ops:  35
compiled vars:  !0 = $array, !1 = $result, !2 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   21     1        ASSIGN                                                   !1, <array>
   22     2      > FE_RESET_R                                       $5      !0, ->27
          3    > > FE_FETCH_R                                               $5, !2, ->27
   23     4    >   FETCH_DIM_R                                      ~6      !2, 'password'
          5        ISSET_ISEMPTY_DIM_OBJ                         0  ~7      !1, ~6
          6        BOOL_NOT                                         ~8      ~7
          7      > JMPZ                                                     ~8, ->12
   24     8    >   FETCH_DIM_R                                      ~9      !2, 'password'
          9        ASSIGN_DIM                                               !1, ~9
         10        OP_DATA                                                  !2
   23    11      > JMP                                                      ->26
   26    12    >   FETCH_DIM_R                                      ~11     !2, 'password'
         13        FETCH_DIM_IS                                     ~12     !1, ~11
         14        ISSET_ISEMPTY_DIM_OBJ                         0          ~12, 'id'
         15      > JMPZ                                                     ~13, ->22
   27    16    >   FETCH_DIM_R                                      ~14     !2, 'password'
         17        FETCH_DIM_R                                      ~16     !2, 'password'
         18        FETCH_DIM_R                                      ~17     !1, ~16
         19        INIT_ARRAY                                       ~18     ~17
         20        ASSIGN_DIM                                               !1, ~14
         21        OP_DATA                                                  ~18
   29    22    >   FETCH_DIM_R                                      ~19     !2, 'password'
         23        FETCH_DIM_W                                      $20     !1, ~19
         24        ASSIGN_DIM                                               $20
         25        OP_DATA                                                  !2
   22    26    > > JMP                                                      ->3
         27    >   FE_FREE                                                  $5
   32    28        INIT_FCALL                                               'var_export'
         29        INIT_FCALL                                               'array_values'
         30        SEND_VAR                                                 !1
         31        DO_ICALL                                         $22     
         32        SEND_VAR                                                 $22
         33        DO_ICALL                                                 
         34      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.06 ms | 1000 KiB | 15 Q