3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ValueException extends Exception { /* You should have something like this already */ } function buildColumnFilter($colnum, $value) { return function($row) use ($colnum, $value) { return isset($row[$colnum]) && $row[$colnum] === $value; }; } function findColNumByName($table, $name) { if (!in_array($name, $table[0])) { throw new ValueException($name); } return array_search($name, $table[0]); } $triggers = array( array('description', 'triggerid'), array('Issue here', 2), array('Issue 3 here', 3), array('Issue 4 here', 4), ); $events = array( array('hostname', 'objectid'), array('john', 2), array('mike', 3), array('mike', 4), ); var_dump(array_filter($triggers, buildColumnFilter(findColNumByName($triggers, 'triggerid'), 2))); var_dump(array_filter($events, buildColumnFilter(findColNumByName($events, 'objectid'), 2)));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1q9O0
function name:  (null)
number of ops:  33
compiled vars:  !0 = $triggers, !1 = $events
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                   !0, <array>
   25     1        ASSIGN                                                   !1, <array>
   32     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'array_filter'
          4        SEND_VAR                                                 !0
          5        INIT_FCALL                                               'buildcolumnfilter'
          6        INIT_FCALL                                               'findcolnumbyname'
          7        SEND_VAR                                                 !0
          8        SEND_VAL                                                 'triggerid'
          9        DO_FCALL                                      0  $4      
         10        SEND_VAR                                                 $4
         11        SEND_VAL                                                 2
         12        DO_FCALL                                      0  $5      
         13        SEND_VAR                                                 $5
         14        DO_ICALL                                         $6      
         15        SEND_VAR                                                 $6
         16        DO_ICALL                                                 
   34    17        INIT_FCALL                                               'var_dump'
         18        INIT_FCALL                                               'array_filter'
         19        SEND_VAR                                                 !1
         20        INIT_FCALL                                               'buildcolumnfilter'
         21        INIT_FCALL                                               'findcolnumbyname'
         22        SEND_VAR                                                 !1
         23        SEND_VAL                                                 'objectid'
         24        DO_FCALL                                      0  $8      
         25        SEND_VAR                                                 $8
         26        SEND_VAL                                                 2
         27        DO_FCALL                                      0  $9      
         28        SEND_VAR                                                 $9
         29        DO_ICALL                                         $10     
         30        SEND_VAR                                                 $10
         31        DO_ICALL                                                 
         32      > RETURN                                                   1

Function buildcolumnfilter:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1q9O0
function name:  buildColumnFilter
number of ops:  7
compiled vars:  !0 = $colnum, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F1q9O0%3A6%240'
          3        BIND_LEXICAL                                             ~2, !0
          4        BIND_LEXICAL                                             ~2, !1
          5      > RETURN                                                   ~2
    7     6*     > RETURN                                                   null

End of function buildcolumnfilter

Function %00%7Bclosure%7D%2Fin%2F1q9O0%3A6%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/1q9O0
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $row, !1 = $colnum, !2 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        BIND_STATIC                                              !2
          3        ISSET_ISEMPTY_DIM_OBJ                         0  ~3      !0, !1
          4      > JMPZ_EX                                          ~3      ~3, ->8
          5    >   FETCH_DIM_R                                      ~4      !0, !1
          6        IS_IDENTICAL                                     ~5      !2, ~4
          7        BOOL                                             ~3      ~5
          8    > > RETURN                                                   ~3
          9*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F1q9O0%3A6%240

Function findcolnumbyname:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 13
Branch analysis from position: 9
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1q9O0
function name:  findColNumByName
number of ops:  20
compiled vars:  !0 = $table, !1 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   10     2        INIT_FCALL                                               'in_array'
          3        SEND_VAR                                                 !1
          4        FETCH_DIM_R                                      ~2      !0, 0
          5        SEND_VAL                                                 ~2
          6        DO_ICALL                                         $3      
          7        BOOL_NOT                                         ~4      $3
          8      > JMPZ                                                     ~4, ->13
   11     9    >   NEW                                              $5      'ValueException'
         10        SEND_VAR_EX                                              !1
         11        DO_FCALL                                      0          
         12      > THROW                                         0          $5
   14    13    >   INIT_FCALL                                               'array_search'
         14        SEND_VAR                                                 !1
         15        FETCH_DIM_R                                      ~7      !0, 0
         16        SEND_VAL                                                 ~7
         17        DO_ICALL                                         $8      
         18      > RETURN                                                   $8
   15    19*     > RETURN                                                   null

End of function findcolnumbyname

Class ValueException: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
181 ms | 1403 KiB | 25 Q