3v4l.org

run code in 300+ PHP versions simultaneously
<?php $vars = ['len' => '-1', 'start' => '0', 'cNum' => '7', 'cSearch_0' => 'b', 'cSearch_1' => 'c', 'cSearch_2' => 'd', 'cSearch_3' => 'e', 'cSearch_4' => 'f', 'cSearch_5' => 'g', 'cSearch_6' => 'h', 'cSort_0' => 'asc', 'cSort_1' => 'asc', 'search' => 'a']; function _filterArrayByKey(string $filter, $array){ return array_filter( $array, function($k) use ($filter){ return preg_match('/(' . $filter . ')/',$k); }, ARRAY_FILTER_USE_KEY ); } // $v = preg_grep('/[cSearch]\_/', array_keys($vars)); // $cSearch = array_filter($vars, function($k){ return preg_match('/(cSearch)/',$k);}, ARRAY_FILTER_USE_KEY); $cVis = _filterArrayByKey('cVis',$vars); var_dump($cVis); if(!empty($cVis)){ $cVisStr = 'columnDefs: [ { targets: [ '; $cVisInd = []; for ($i = 0; $i < $vars['cNum']; $i++){ if(array_key_exists('cVis_' . $i, $cVis)){ $cVisInd[] = (int) $i; } } $cVisStr .= implode(',',$cVisInd) .'], visible: false} ]'; $jsout[] = $cVisStr; } var_dump($cVisStr);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 34
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 16
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 22
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 16
Branch analysis from position: 26
Branch analysis from position: 16
Branch analysis from position: 22
Branch analysis from position: 34
filename:       /in/ohZqo
function name:  (null)
number of ops:  38
compiled vars:  !0 = $vars, !1 = $cVis, !2 = $cVisStr, !3 = $cVisInd, !4 = $i, !5 = $jsout
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   30     1        INIT_FCALL                                               '_filterarraybykey'
          2        SEND_VAL                                                 'cVis'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $7      
          5        ASSIGN                                                   !1, $7
   31     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                                 
   33     9        ISSET_ISEMPTY_CV                                 ~10     !1
         10        BOOL_NOT                                         ~11     ~10
         11      > JMPZ                                                     ~11, ->34
   34    12    >   ASSIGN                                                   !2, 'columnDefs%3A+%5B+%7B+targets%3A+%5B+'
   35    13        ASSIGN                                                   !3, <array>
   36    14        ASSIGN                                                   !4, 0
         15      > JMP                                                      ->23
   37    16    >   CONCAT                                           ~15     'cVis_', !4
         17        ARRAY_KEY_EXISTS                                         ~15, !1
         18      > JMPZ                                                     ~16, ->22
   38    19    >   CAST                                          4  ~18     !4
         20        ASSIGN_DIM                                               !3
         21        OP_DATA                                                  ~18
   36    22    >   PRE_INC                                                  !4
         23    >   FETCH_DIM_R                                      ~20     !0, 'cNum'
         24        IS_SMALLER                                               !4, ~20
         25      > JMPNZ                                                    ~21, ->16
   41    26    >   INIT_FCALL                                               'implode'
         27        SEND_VAL                                                 '%2C'
         28        SEND_VAR                                                 !3
         29        DO_ICALL                                         $22     
         30        CONCAT                                           ~23     $22, '%5D%2C+visible%3A+false%7D+%5D'
         31        ASSIGN_OP                                     8          !2, ~23
   42    32        ASSIGN_DIM                                               !5
         33        OP_DATA                                                  !2
   45    34    >   INIT_FCALL                                               'var_dump'
         35        SEND_VAR                                                 !2
         36        DO_ICALL                                                 
         37      > RETURN                                                   1

Function _filterarraybykey:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ohZqo
function name:  _filterArrayByKey
number of ops:  11
compiled vars:  !0 = $filter, !1 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   18     2        INIT_FCALL                                               'array_filter'
   19     3        SEND_VAR                                                 !1
   20     4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FohZqo%3A20%240'
          5        BIND_LEXICAL                                             ~2, !0
   22     6        SEND_VAL                                                 ~2
   23     7        SEND_VAL                                                 2
          8        DO_ICALL                                         $3      
          9      > RETURN                                                   $3
   25    10*     > RETURN                                                   null

End of function _filterarraybykey

Function %00%7Bclosure%7D%2Fin%2FohZqo%3A20%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ohZqo
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $k, !1 = $filter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   21     2        INIT_FCALL                                               'preg_match'
          3        CONCAT                                           ~2      '%2F%28', !1
          4        CONCAT                                           ~3      ~2, '%29%2F'
          5        SEND_VAL                                                 ~3
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $4      
          8      > RETURN                                                   $4
   22     9*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FohZqo%3A20%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.34 ms | 1403 KiB | 22 Q