3v4l.org

run code in 300+ PHP versions simultaneously
<?php $ingredients = [ ['name' => 'TV','amount' => 3], ['name' => 'LAPTOP', 'amount' => 2], ['name' => 'HAREM', 'amount' => 2], ['name' => 'OIL', 'amount' => 1], ['name' => 'Windows', 'amount' => 1], ['name' => 'Something', 'amount' => 1] ]; $prices = [ 'TV' => 20, 'LAPTOP' => 20, 'HAREM' => 25, 'OIL' => 20, 'Windows' => 25, 'Something' => 35 ]; $name = array_column($ingredients,"name"); Foreach($prices as $item => $price){ $find = array_search($item, $name); If($find !== false) $res[$item] = $price * $ingredients[$find]['amount']; } Var_dump($res);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 23
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 23
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 22
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 22
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/oHCCN
function name:  (null)
number of ops:  28
compiled vars:  !0 = $ingredients, !1 = $prices, !2 = $name, !3 = $price, !4 = $item, !5 = $find, !6 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   12     1        ASSIGN                                                   !1, <array>
   21     2        INIT_FCALL                                               'array_column'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 'name'
          5        DO_ICALL                                         $9      
          6        ASSIGN                                                   !2, $9
   22     7      > FE_RESET_R                                       $11     !1, ->23
          8    > > FE_FETCH_R                                       ~12     $11, !3, ->23
          9    >   ASSIGN                                                   !4, ~12
   23    10        INIT_FCALL                                               'array_search'
         11        SEND_VAR                                                 !4
         12        SEND_VAR                                                 !2
         13        DO_ICALL                                         $14     
         14        ASSIGN                                                   !5, $14
   24    15        TYPE_CHECK                                  1018          !5
         16      > JMPZ                                                     ~16, ->22
         17    >   FETCH_DIM_R                                      ~18     !0, !5
         18        FETCH_DIM_R                                      ~19     ~18, 'amount'
         19        MUL                                              ~20     !3, ~19
         20        ASSIGN_DIM                                               !6, !4
         21        OP_DATA                                                  ~20
   22    22    > > JMP                                                      ->8
         23    >   FE_FREE                                                  $11
   27    24        INIT_FCALL                                               'var_dump'
         25        SEND_VAR                                                 !6
         26        DO_ICALL                                                 
         27      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.59 ms | 1001 KiB | 16 Q