3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a=array( "Nike"=>"sports, clothing", "Ford"=>"cars, outdoors", "Patagonia"=>"clothing, outdoors" ); $search = 'clothing'; echo array_search("clothing",$a); // should output Nike and Patagonia $filter = array_filter($a, function($item) use ($search){ return in_array($search, explode(', ', $item)); }); print_r($filter);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VvcPs
function name:  (null)
number of ops:  18
compiled vars:  !0 = $a, !1 = $search, !2 = $filter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    9     1        ASSIGN                                                   !1, 'clothing'
   10     2        INIT_FCALL                                               'array_search'
          3        SEND_VAL                                                 'clothing'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $5      
          6        ECHO                                                     $5
   11     7        INIT_FCALL                                               'array_filter'
          8        SEND_VAR                                                 !0
          9        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FVvcPs%3A11%240'
         10        BIND_LEXICAL                                             ~6, !1
   13    11        SEND_VAL                                                 ~6
         12        DO_ICALL                                         $7      
   11    13        ASSIGN                                                   !2, $7
   14    14        INIT_FCALL                                               'print_r'
         15        SEND_VAR                                                 !2
         16        DO_ICALL                                                 
         17      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FVvcPs%3A11%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VvcPs
function name:  {closure}
number of ops:  12
compiled vars:  !0 = $item, !1 = $search
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   12     2        INIT_FCALL                                               'in_array'
          3        SEND_VAR                                                 !1
          4        INIT_FCALL                                               'explode'
          5        SEND_VAL                                                 '%2C+'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $2      
          8        SEND_VAR                                                 $2
          9        DO_ICALL                                         $3      
         10      > RETURN                                                   $3
   13    11*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FVvcPs%3A11%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.82 ms | 1396 KiB | 23 Q