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); $o = ''; if(!empty($cVis)){ $cVisStr = 'columnDefs: [ { targets: [ '; $cVisInd = []; for ($i = 0; $i < $vars['cNum']; $i++){ if(array_key_exists('cVis_' . $i, $cVis)){ $cVisInd[] = (int) $i; } } $o = $cVisStr .= implode(',',$cVisInd) .'], visible: false} ]'; $jsout[] = $cVisStr; } var_dump($o);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 36
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 17
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 23
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 17
Branch analysis from position: 27
Branch analysis from position: 17
Branch analysis from position: 23
Branch analysis from position: 36
filename:       /in/LVXq8
function name:  (null)
number of ops:  40
compiled vars:  !0 = $vars, !1 = $cVis, !2 = $o, !3 = $cVisStr, !4 = $cVisInd, !5 = $i, !6 = $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  $8      
          5        ASSIGN                                                   !1, $8
   31     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                                 
   32     9        ASSIGN                                                   !2, ''
   33    10        ISSET_ISEMPTY_CV                                 ~12     !1
         11        BOOL_NOT                                         ~13     ~12
         12      > JMPZ                                                     ~13, ->36
   34    13    >   ASSIGN                                                   !3, 'columnDefs%3A+%5B+%7B+targets%3A+%5B+'
   35    14        ASSIGN                                                   !4, <array>
   36    15        ASSIGN                                                   !5, 0
         16      > JMP                                                      ->24
   37    17    >   CONCAT                                           ~17     'cVis_', !5
         18        ARRAY_KEY_EXISTS                                         ~17, !1
         19      > JMPZ                                                     ~18, ->23
   38    20    >   CAST                                          4  ~20     !5
         21        ASSIGN_DIM                                               !4
         22        OP_DATA                                                  ~20
   36    23    >   PRE_INC                                                  !5
         24    >   FETCH_DIM_R                                      ~22     !0, 'cNum'
         25        IS_SMALLER                                               !5, ~22
         26      > JMPNZ                                                    ~23, ->17
   41    27    >   INIT_FCALL                                               'implode'
         28        SEND_VAL                                                 '%2C'
         29        SEND_VAR                                                 !4
         30        DO_ICALL                                         $24     
         31        CONCAT                                           ~25     $24, '%5D%2C+visible%3A+false%7D+%5D'
         32        ASSIGN_OP                                     8  ~26     !3, ~25
         33        ASSIGN                                                   !2, ~26
   42    34        ASSIGN_DIM                                               !6
         35        OP_DATA                                                  !3
   45    36    >   INIT_FCALL                                               'var_dump'
         37        SEND_VAR                                                 !2
         38        DO_ICALL                                                 
         39      > RETURN                                                   1

Function _filterarraybykey:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LVXq8
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%2FLVXq8%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%2FLVXq8%3A20%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LVXq8
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%2FLVXq8%3A20%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.77 ms | 1403 KiB | 22 Q