3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array ( 0 => array ( 'vehicle' => 'BUS NO.1', 'trip_name' => 'Trip00011', 'running_km' => '5000', ), 1 => array ( 'vehicle' => 'BUS NO.2', 'trip_name' => 'Trip00021', 'running_km' => '2400', ), 2 => array ( 'vehicle' => 'BUS NO.1', 'trip_name' => 'Trip00011', 'running_km' => '0', ), 3 => array ( 'vehicle' => 'BUS NO.2', 'trip_name' => 'Trip00011', 'running_km' => '0', ), 4 => array ( 'vehicle' => 'BUS NO.2', 'trip_name' => 'Trip00021', 'running_km' => '0', ), ); foreach($arr as $item){ $key = $item['vehicle'] . $item['trip_name']; if(isset($new[$key])){ if($item['running_km'] > $new[$key]['running_km']) $new[$key] = $item; }else{ $new[$key] = $item; } } $new = array_values($new); Var_dump($new);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 20
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 20
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 17
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 16
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/4qX7q
function name:  (null)
number of ops:  29
compiled vars:  !0 = $arr, !1 = $item, !2 = $key, !3 = $new
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   36     1      > FE_RESET_R                                       $5      !0, ->20
          2    > > FE_FETCH_R                                               $5, !1, ->20
   37     3    >   FETCH_DIM_R                                      ~6      !1, 'vehicle'
          4        FETCH_DIM_R                                      ~7      !1, 'trip_name'
          5        CONCAT                                           ~8      ~6, ~7
          6        ASSIGN                                                   !2, ~8
   38     7        ISSET_ISEMPTY_DIM_OBJ                         0          !3, !2
          8      > JMPZ                                                     ~10, ->17
   39     9    >   FETCH_DIM_R                                      ~11     !1, 'running_km'
         10        FETCH_DIM_R                                      ~12     !3, !2
         11        FETCH_DIM_R                                      ~13     ~12, 'running_km'
         12        IS_SMALLER                                               ~13, ~11
         13      > JMPZ                                                     ~14, ->16
         14    >   ASSIGN_DIM                                               !3, !2
         15        OP_DATA                                                  !1
   38    16    > > JMP                                                      ->19
   41    17    >   ASSIGN_DIM                                               !3, !2
         18        OP_DATA                                                  !1
   36    19    > > JMP                                                      ->2
         20    >   FE_FREE                                                  $5
   45    21        INIT_FCALL                                               'array_values'
         22        SEND_VAR                                                 !3
         23        DO_ICALL                                         $17     
         24        ASSIGN                                                   !3, $17
   47    25        INIT_FCALL                                               'var_dump'
         26        SEND_VAR                                                 !3
         27        DO_ICALL                                                 
         28      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.55 ms | 1012 KiB | 15 Q