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' ), ); $arr2 = array_msort($messages, array('call-id'=>SORT_ASC, 'type'=>SORT_ASC)); print_r($arr2); foreach ($messages as $message => $value) { if(in_array($value['call-id'], $newArray)) { $keyToDelete[] = $message; } else { $newArray[$value['call-id']] = $value['call-id']; } } foreach($keyToDelete as $key => $val) { if($messages[$val]['type'] == 'voice') { unset($messages[$val]); } } print_r($messages);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 26
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 26
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 26
2 jumps found. (Code = 77) Position 1 = 28, Position 2 = 36
Branch analysis from position: 28
2 jumps found. (Code = 78) Position 1 = 29, Position 2 = 36
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 35
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
Branch analysis from position: 35
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
Branch analysis from position: 26
filename:       /in/6P2gi
function name:  (null)
number of ops:  41
compiled vars:  !0 = $messages, !1 = $arr2, !2 = $value, !3 = $message, !4 = $newArray, !5 = $keyToDelete, !6 = $val, !7 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   31     1        INIT_FCALL_BY_NAME                                       'array_msort'
          2        SEND_VAR_EX                                              !0
          3        SEND_VAL_EX                                              <array>
          4        DO_FCALL                                      0  $9      
          5        ASSIGN                                                   !1, $9
   32     6        INIT_FCALL                                               'print_r'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                                 
   33     9      > FE_RESET_R                                       $12     !0, ->26
         10    > > FE_FETCH_R                                       ~13     $12, !2, ->26
         11    >   ASSIGN                                                   !3, ~13
   34    12        INIT_FCALL                                               'in_array'
         13        FETCH_DIM_R                                      ~15     !2, 'call-id'
         14        SEND_VAL                                                 ~15
         15        SEND_VAR                                                 !4
         16        DO_ICALL                                         $16     
         17      > JMPZ                                                     $16, ->21
   35    18    >   ASSIGN_DIM                                               !5
         19        OP_DATA                                                  !3
         20      > JMP                                                      ->25
   37    21    >   FETCH_DIM_R                                      ~18     !2, 'call-id'
         22        FETCH_DIM_R                                      ~20     !2, 'call-id'
         23        ASSIGN_DIM                                               !4, ~18
         24        OP_DATA                                                  ~20
   33    25    > > JMP                                                      ->10
         26    >   FE_FREE                                                  $12
   41    27      > FE_RESET_R                                       $21     !5, ->36
         28    > > FE_FETCH_R                                       ~22     $21, !6, ->36
         29    >   ASSIGN                                                   !7, ~22
   42    30        FETCH_DIM_R                                      ~24     !0, !6
         31        FETCH_DIM_R                                      ~25     ~24, 'type'
         32        IS_EQUAL                                                 ~25, 'voice'
         33      > JMPZ                                                     ~26, ->35
   43    34    >   UNSET_DIM                                                !0, !6
   41    35    > > JMP                                                      ->28
         36    >   FE_FREE                                                  $21
   47    37        INIT_FCALL                                               'print_r'
         38        SEND_VAR                                                 !0
         39        DO_ICALL                                                 
         40      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.93 ms | 1404 KiB | 18 Q