3v4l.org

run code in 500+ PHP versions simultaneously
<?php $inputArr = [ [ 'title' => 'Test0', 'desc' => 'Short Desc', ], [ 'title' => 'Test5', 'desc' => 'Short Desc', ], [ 'title' => 'Test0', 'desc' => 'Much Longer Than Short Desc', ], [ 'title' => 'Test0.5', 'desc' => 'Short Desc', ], [ 'title' => 'Test1', 'desc' => 'Short Desc', ], [ 'title' => 'Test1', 'desc' => 'Much Longer Than Short Desc', ], [ 'title' => 'Test1.5', 'desc' => 'Much Longer Than Short Desc', ], [ 'title' => 'Test3', 'desc' => 'Short Desc', ], [ 'title' => 'Test2', 'desc' => 'Short Desc', ], [ 'title' => 'Test3.75', 'desc' => 'Much Longer Than Short Desc', ], [ 'title' => 'Test3.25', 'desc' => 'Short Desc', ], [ 'title' => 'Test2', 'desc' => 'Much Longer Than Short Desc', ], [ 'title' => 'Test3', 'desc' => 'Much Longer Than Short Desc', ], [ 'title' => 'Test5', 'desc' => 'Much Longer Than Short Desc', ], [ 'title' => 'Test3.5', 'desc' => 'Short Desc', ], [ 'title' => 'Test4', 'desc' => 'Short Desc', ], [ 'title' => 'Test5', 'desc' => 'Much Longer Than Short Desc', ], [ 'title' => 'Test4.5', 'desc' => 'Short Desc', ], [ 'title' => 'Test4', 'desc' => 'Much Longer Than Short Desc', ], [ 'title' => 'Test5', 'desc' => 'Much Longer Than Short Desc', ], ]; $result = []; foreach($inputArr as $item) { if ( isset($result[$item['title']]) && strlen($result[$item['title']]['desc']) > strlen($item['desc']) ) continue; $result[$item['title']] = $item; } $result = array_values($result); print_r($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 21
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 21
Branch analysis from position: 4
2 jumps found. (Code = 46) Position 1 = 7, Position 2 = 15
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 17
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 15
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/3GdjY
function name:  (null)
number of ops:  30
compiled vars:  !0 = $inputArr, !1 = $result, !2 = $item
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   86     1        ASSIGN                                                       !1, <array>
   88     2      > FE_RESET_R                                           $5      !0, ->21
          3    > > FE_FETCH_R                                                   $5, !2, ->21
   90     4    >   FETCH_DIM_R                                          ~6      !2, 'title'
          5        ISSET_ISEMPTY_DIM_OBJ                             0  ~7      !1, ~6
          6      > JMPZ_EX                                              ~7      ~7, ->15
          7    >   FETCH_DIM_R                                          ~8      !2, 'title'
          8        FETCH_DIM_R                                          ~9      !1, ~8
          9        FETCH_DIM_R                                          ~10     ~9, 'desc'
         10        STRLEN                                               ~11     ~10
         11        FETCH_DIM_R                                          ~12     !2, 'desc'
         12        STRLEN                                               ~13     ~12
         13        IS_SMALLER                                           ~14     ~13, ~11
         14        BOOL                                                 ~7      ~14
         15    > > JMPZ                                                         ~7, ->17
   91    16    > > JMP                                                          ->3
   93    17    >   FETCH_DIM_R                                          ~15     !2, 'title'
         18        ASSIGN_DIM                                                   !1, ~15
         19        OP_DATA                                                      !2
   88    20      > JMP                                                          ->3
         21    >   FE_FREE                                                      $5
   96    22        INIT_FCALL                                                   'array_values'
         23        SEND_VAR                                                     !1
         24        DO_ICALL                                             $17     
         25        ASSIGN                                                       !1, $17
   98    26        INIT_FCALL                                                   'print_r'
         27        SEND_VAR                                                     !1
         28        DO_ICALL                                                     
         29      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
227.69 ms | 2377 KiB | 15 Q