3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr[] = ["model_id" => 1, "price" => 2000]; $arr[] = ["model_id" => 2, "price" => 3000]; $arr[] = ["model_id" => 1, "price" => 1500]; $res = []; foreach($arr as $e) { if (isset($res[$e["model_id"]])) $res[$e["model_id"]]["price"] = min($res[$e["model_id"]]["price"], $e["price"]); else $res[$e["model_id"]] = $e; } print_r($res);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 29
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 29
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 25
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/0CKL2
function name:  (null)
number of ops:  34
compiled vars:  !0 = $arr, !1 = $res, !2 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN_DIM                                               !0
          1        OP_DATA                                                  <array>
    4     2        ASSIGN_DIM                                               !0
          3        OP_DATA                                                  <array>
    5     4        ASSIGN_DIM                                               !0
          5        OP_DATA                                                  <array>
    7     6        ASSIGN                                                   !1, <array>
    8     7      > FE_RESET_R                                       $7      !0, ->29
          8    > > FE_FETCH_R                                               $7, !2, ->29
    9     9    >   FETCH_DIM_R                                      ~8      !2, 'model_id'
         10        ISSET_ISEMPTY_DIM_OBJ                         0          !1, ~8
         11      > JMPZ                                                     ~9, ->25
   10    12    >   FETCH_DIM_R                                      ~10     !2, 'model_id'
         13        INIT_FCALL                                               'min'
         14        FETCH_DIM_R                                      ~13     !2, 'model_id'
         15        FETCH_DIM_R                                      ~14     !1, ~13
         16        FETCH_DIM_R                                      ~15     ~14, 'price'
         17        SEND_VAL                                                 ~15
         18        FETCH_DIM_R                                      ~16     !2, 'price'
         19        SEND_VAL                                                 ~16
         20        DO_ICALL                                         $17     
         21        FETCH_DIM_W                                      $11     !1, ~10
         22        ASSIGN_DIM                                               $11, 'price'
         23        OP_DATA                                                  $17
    9    24      > JMP                                                      ->28
   11    25    >   FETCH_DIM_R                                      ~18     !2, 'model_id'
         26        ASSIGN_DIM                                               !1, ~18
         27        OP_DATA                                                  !2
    8    28    > > JMP                                                      ->8
         29    >   FE_FREE                                                  $7
   15    30        INIT_FCALL                                               'print_r'
         31        SEND_VAR                                                 !1
         32        DO_ICALL                                                 
         33      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.08 ms | 1012 KiB | 15 Q