3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array(array('name' => 'Bob', 'alive' => false), array('Name' => 'Jim', 'alive' => true), array('Name' => 'Alice', 'alive' => false)); function array_find($arr, $key, $val){ $ret = []; foreach($arr as $elem ){ if($elem[$key] == $val){ $ret []= $elem; } } return $ret; } var_dump(array_find($array, 'alive', false));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tt1Pf
function name:  (null)
number of ops:  10
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   15     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'array_find'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 'alive'
          5        SEND_VAL                                                 <false>
          6        DO_FCALL                                      0  $2      
          7        SEND_VAR                                                 $2
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function array_find:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 11
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/tt1Pf
function name:  array_find
number of ops:  15
compiled vars:  !0 = $arr, !1 = $key, !2 = $val, !3 = $ret, !4 = $elem
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    6     3        ASSIGN                                                   !3, <array>
    7     4      > FE_RESET_R                                       $6      !0, ->12
          5    > > FE_FETCH_R                                               $6, !4, ->12
    8     6    >   FETCH_DIM_R                                      ~7      !4, !1
          7        IS_EQUAL                                                 !2, ~7
          8      > JMPZ                                                     ~8, ->11
    9     9    >   ASSIGN_DIM                                               !3
         10        OP_DATA                                                  !4
    7    11    > > JMP                                                      ->5
         12    >   FE_FREE                                                  $6
   12    13      > RETURN                                                   !3
   13    14*     > RETURN                                                   null

End of function array_find

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.07 ms | 1399 KiB | 16 Q