3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arr = [ ['region' => 'a', 'name' => 'a'], ['region' => 'b', 'name' => 'b'], ['region' => 'c', 'name' => 'c'], ]; $find = 'b'; // print_r($arr[array_search($find, array_column($arr, 'region'))]); // print_r(array_values(array_filter($arr, fn($v) => $v['region'] === $find))[0]); // print_r(array_reduce($arr, function($acc, $curr) use($find) { if ($curr['region'] === $find) { $acc = $curr; } return $acc; }, []));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mZ02t
function name:  (null)
number of ops:  38
compiled vars:  !0 = $arr, !1 = $find
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    9     1        ASSIGN                                                       !1, 'b'
   12     2        INIT_FCALL                                                   'print_r'
          3        INIT_FCALL                                                   'array_search'
          4        SEND_VAR                                                     !1
          5        INIT_FCALL                                                   'array_column'
          6        SEND_VAR                                                     !0
          7        SEND_VAL                                                     'region'
          8        DO_ICALL                                             $4      
          9        SEND_VAR                                                     $4
         10        DO_ICALL                                             $5      
         11        FETCH_DIM_R                                          ~6      !0, $5
         12        SEND_VAL                                                     ~6
         13        DO_ICALL                                                     
   15    14        INIT_FCALL                                                   'print_r'
         15        INIT_FCALL                                                   'array_values'
         16        INIT_FCALL                                                   'array_filter'
         17        SEND_VAR                                                     !0
         18        DECLARE_LAMBDA_FUNCTION                              ~8      [0]
         19        BIND_LEXICAL                                                 ~8, !1
         20        SEND_VAL                                                     ~8
         21        DO_ICALL                                             $9      
         22        SEND_VAR                                                     $9
         23        DO_ICALL                                             $10     
         24        FETCH_DIM_R                                          ~11     $10, 0
         25        SEND_VAL                                                     ~11
         26        DO_ICALL                                                     
   18    27        INIT_FCALL                                                   'print_r'
         28        INIT_FCALL                                                   'array_reduce'
         29        SEND_VAR                                                     !0
         30        DECLARE_LAMBDA_FUNCTION                              ~13     [1]
         31        BIND_LEXICAL                                                 ~13, !1
   23    32        SEND_VAL                                                     ~13
         33        SEND_VAL                                                     <array>
   18    34        DO_ICALL                                             $14     
   23    35        SEND_VAR                                                     $14
   18    36        DO_ICALL                                                     
   23    37      > 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/mZ02t
function name:  {closure:/in/mZ02t:15}
number of ops:  6
compiled vars:  !0 = $v, !1 = $find
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
          2        FETCH_DIM_R                                          ~2      !0, 'region'
          3        IS_IDENTICAL                                         ~3      !1, ~2
          4      > RETURN                                                       ~3
          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 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/mZ02t
function name:  {closure:/in/mZ02t:18}
number of ops:  9
compiled vars:  !0 = $acc, !1 = $curr, !2 = $find
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        BIND_STATIC                                                  !2
   19     3        FETCH_DIM_R                                          ~3      !1, 'region'
          4        IS_IDENTICAL                                                 !2, ~3
          5      > JMPZ                                                         ~4, ->7
   20     6    >   ASSIGN                                                       !0, !1
   22     7    > > RETURN                                                       !0
   23     8*     > RETURN                                                       null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
173.01 ms | 2038 KiB | 18 Q