3v4l.org

run code in 300+ PHP versions simultaneously
<?php $messages = array( 'message1'=>array( 'type'=>'voice', 'call-id'=>'11', 'id'=>'message1' ), 'message2'=>array( 'type'=>'voice', 'call-id'=>'44', 'id'=>'message2' ), 'message3'=>array( 'type'=>'text', 'call-id'=>'44', 'id'=>'message3' ), 'message4'=>array( 'type'=>'text', 'call-id'=>'55', 'id'=>'message4' ), 'message5'=>array( 'type'=>'voice', 'call-id'=>'55', 'id'=>'message5' ), ); foreach ($messages as $message => $value) { $unique[$value['call-id']] = $value; // this will override the previous value with the same key if exists } foreach ($unique as $key => $value) { $array[$value['id']] = $value; } echo '<pre>'; print_r($array);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 8
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 8
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 8
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 16
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
Branch analysis from position: 8
filename:       /in/njkoM
function name:  (null)
number of ops:  22
compiled vars:  !0 = $messages, !1 = $value, !2 = $message, !3 = $unique, !4 = $key, !5 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   32     1      > FE_RESET_R                                       $7      !0, ->8
          2    > > FE_FETCH_R                                       ~8      $7, !1, ->8
          3    >   ASSIGN                                                   !2, ~8
   33     4        FETCH_DIM_R                                      ~10     !1, 'call-id'
          5        ASSIGN_DIM                                               !3, ~10
          6        OP_DATA                                                  !1
   32     7      > JMP                                                      ->2
          8    >   FE_FREE                                                  $7
   37     9      > FE_RESET_R                                       $12     !3, ->16
         10    > > FE_FETCH_R                                       ~13     $12, !1, ->16
         11    >   ASSIGN                                                   !4, ~13
   38    12        FETCH_DIM_R                                      ~15     !1, 'id'
         13        ASSIGN_DIM                                               !5, ~15
         14        OP_DATA                                                  !1
   37    15      > JMP                                                      ->10
         16    >   FE_FREE                                                  $12
   41    17        ECHO                                                     '%3Cpre%3E'
   42    18        INIT_FCALL                                               'print_r'
         19        SEND_VAR                                                 !5
         20        DO_ICALL                                                 
         21      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
213.4 ms | 1400 KiB | 15 Q