3v4l.org

run code in 500+ PHP versions simultaneously
<?php $items = [ ["item_a" =>3,"valor_a" =>396], ["item_a" =>3,"valor_a" =>1514], ["item_a" =>3,"valor_a" =>2106], ["item_a" =>6,"valor_a" =>1020], ["item_a" =>4,"valor_a" =>1319], ["item_a" =>11,"valor_a" =>1912] ]; $search = 3; $newArray = array_filter($items, function($item) use($search) { return $item['item_a'] == $search; }); print_r($newArray); $newArray2 = array_map(function($item) use($search) { if ($item['item_a'] == $search) { return $item['valor_a']; } },$items); print_r(array_filter($newArray2));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uPRHp
function name:  (null)
number of ops:  26
compiled vars:  !0 = $items, !1 = $search, !2 = $newArray, !3 = $newArray2
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   11     1        ASSIGN                                                       !1, 3
   12     2        INIT_FCALL                                                   'array_filter'
          3        SEND_VAR                                                     !0
          4        DECLARE_LAMBDA_FUNCTION                              ~6      [0]
          5        BIND_LEXICAL                                                 ~6, !1
   14     6        SEND_VAL                                                     ~6
   12     7        DO_ICALL                                             $7      
          8        ASSIGN                                                       !2, $7
   16     9        INIT_FCALL                                                   'print_r'
         10        SEND_VAR                                                     !2
         11        DO_ICALL                                                     
   18    12        INIT_FCALL                                                   'array_map'
         13        DECLARE_LAMBDA_FUNCTION                              ~10     [1]
         14        BIND_LEXICAL                                                 ~10, !1
   22    15        SEND_VAL                                                     ~10
         16        SEND_VAR                                                     !0
   18    17        DO_ICALL                                             $11     
         18        ASSIGN                                                       !3, $11
   24    19        INIT_FCALL                                                   'print_r'
         20        INIT_FCALL                                                   'array_filter'
         21        SEND_VAR                                                     !3
         22        DO_ICALL                                             $13     
         23        SEND_VAR                                                     $13
         24        DO_ICALL                                                     
         25      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uPRHp
function name:  {closure:/in/uPRHp:12}
number of ops:  6
compiled vars:  !0 = $item, !1 = $search
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   12     0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
   13     2        FETCH_DIM_R                                          ~2      !0, 'item_a'
          3        IS_EQUAL                                             ~3      !1, ~2
          4      > RETURN                                                       ~3
   14     5*     > RETURN                                                       null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uPRHp
function name:  {closure:/in/uPRHp:18}
number of ops:  8
compiled vars:  !0 = $item, !1 = $search
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
   19     2        FETCH_DIM_R                                          ~2      !0, 'item_a'
          3        IS_EQUAL                                                     !1, ~2
          4      > JMPZ                                                         ~3, ->7
   20     5    >   FETCH_DIM_R                                          ~4      !0, 'valor_a'
          6      > RETURN                                                       ~4
   22     7    > > RETURN                                                       null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
165.78 ms | 2073 KiB | 16 Q