3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ [ "id" => '6230061c0e88d709ca0d7bbc', 'name' => 'Mobile SamSung', 'slug' => 'mobile-samsung', 'createdAt' => '1648006346' ], [ "id" => '5d1eff529a426778d4b92383', 'name' => 'Mobile Iphone', 'slug' => 'mobile-iphone', 'createdAt' => '1647314181' ], [ "id" => '5d1eff6b9a426778d4b92dc4', 'name' => 'Mobile SamSung', 'slug' => 'mobile-samsung', 'createdAt' => '1647314460' ], [ "id" => '5f894011266aea580b028cb0', 'name' => 'Mobile LG', 'slug' => 'mobile-lg', 'createdAt' => '1647314456' ] ]; $result = []; foreach ($arr as $row) { if (!isset($result[$row['name']]) || (int)$row['createdAt'] > (int)$result[$row['name']]['createdAt']) { $result[$row['name']] = $row; } } var_export(array_values($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 = 47) Position 1 = 8, Position 2 = 16
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 20
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 20
Branch analysis from position: 16
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/RTOrF
function name:  (null)
number of ops:  29
compiled vars:  !0 = $arr, !1 = $result, !2 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   33     1        ASSIGN                                                   !1, <array>
   34     2      > FE_RESET_R                                       $5      !0, ->21
          3    > > FE_FETCH_R                                               $5, !2, ->21
   35     4    >   FETCH_DIM_R                                      ~6      !2, 'name'
          5        ISSET_ISEMPTY_DIM_OBJ                         0  ~7      !1, ~6
          6        BOOL_NOT                                         ~8      ~7
          7      > JMPNZ_EX                                         ~8      ~8, ->16
          8    >   FETCH_DIM_R                                      ~9      !2, 'createdAt'
          9        CAST                                          4  ~10     ~9
         10        FETCH_DIM_R                                      ~11     !2, 'name'
         11        FETCH_DIM_R                                      ~12     !1, ~11
         12        FETCH_DIM_R                                      ~13     ~12, 'createdAt'
         13        CAST                                          4  ~14     ~13
         14        IS_SMALLER                                       ~15     ~14, ~10
         15        BOOL                                             ~8      ~15
         16    > > JMPZ                                                     ~8, ->20
   36    17    >   FETCH_DIM_R                                      ~16     !2, 'name'
         18        ASSIGN_DIM                                               !1, ~16
         19        OP_DATA                                                  !2
   34    20    > > JMP                                                      ->3
         21    >   FE_FREE                                                  $5
   39    22        INIT_FCALL                                               'var_export'
         23        INIT_FCALL                                               'array_values'
         24        SEND_VAR                                                 !1
         25        DO_ICALL                                         $18     
         26        SEND_VAR                                                 $18
         27        DO_ICALL                                                 
         28      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168 ms | 1396 KiB | 17 Q