3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isEmptyArray($item) { if (is_array($item)) { return array_filter($item, 'isEmptyArray'); } if (!empty($item) || $item === "0") { return true; } return false; } function removeEmptyArrays($array) { $filteredArray = array_filter($array, 'isEmptyArray'); return $filteredArray; } function isMultiDimensional($array) { if(is_array($array)) { foreach ($array as $key=>$value){ if(is_array($value)){ return true; } } } return false; } $str='discount_rule[0][service_no][0][service_nos]=100';//'service[0][tier][0][schedule][0][amount]=10'; parse_str($str, $output); $cat='admintools-api'; $options = array(); $apiLiveOptions = array(); foreach ($output AS $key => $value) { if (is_array($value)) { if (!empty($value[$key])) { $options[$key] = $value; $apiLiveOptions[$key] = $value; } else { $array = array(); $apiLiveArray = array(); foreach ($value as $k => $v) { if(!empty($v[$k])) { $array[] = $value[$k]; $apiLiveArray[] = $value[$k]; $options[$key] = $array; } else { $newArray = array_filter($v, 'isEmptyArray'); $apiLiveArray[$k] = $newArray; foreach($newArray as $row => $column) { if(is_array($column)) { foreach($column as $r=>$c) { if($cat=='admintools-api') { var_dump($c); var_dump(count(array_values($c)[0])); //$options[$key][$k][$row][$r]=array_values($c)[0]; } else { $options[$row][$r]=$c; } } } else { if($cat=='admintools-api') { $key == $row ? $options[$key][$k] = $column : $options[$key][$k][$row] = $column; } else { $array[$k]=$column; $options[$row] = $array; } } } } } $apiLiveOptions[$key] = $apiLiveArray; } } else { $options[$key] = $value; $apiLiveOptions[$key] = $value; } }; //var_dump($apiLiveOptions); ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 105
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 105
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 100
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 21
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 99
Branch analysis from position: 99
1 jumps found. (Code = 42) Position 1 = 104
Branch analysis from position: 104
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 21
2 jumps found. (Code = 77) Position 1 = 24, Position 2 = 96
Branch analysis from position: 24
2 jumps found. (Code = 78) Position 1 = 25, Position 2 = 96
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 38
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 95
Branch analysis from position: 95
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 38
2 jumps found. (Code = 77) Position 1 = 46, Position 2 = 94
Branch analysis from position: 46
2 jumps found. (Code = 78) Position 1 = 47, Position 2 = 94
Branch analysis from position: 47
2 jumps found. (Code = 43) Position 1 = 50, Position 2 = 73
Branch analysis from position: 50
2 jumps found. (Code = 77) Position 1 = 51, Position 2 = 71
Branch analysis from position: 51
2 jumps found. (Code = 78) Position 1 = 52, Position 2 = 71
Branch analysis from position: 52
2 jumps found. (Code = 43) Position 1 = 55, Position 2 = 67
Branch analysis from position: 55
1 jumps found. (Code = 42) Position 1 = 70
Branch analysis from position: 70
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
Branch analysis from position: 67
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
Branch analysis from position: 71
1 jumps found. (Code = 42) Position 1 = 93
Branch analysis from position: 93
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
Branch analysis from position: 71
Branch analysis from position: 73
2 jumps found. (Code = 43) Position 1 = 75, Position 2 = 89
Branch analysis from position: 75
2 jumps found. (Code = 43) Position 1 = 77, Position 2 = 82
Branch analysis from position: 77
1 jumps found. (Code = 42) Position 1 = 87
Branch analysis from position: 87
1 jumps found. (Code = 42) Position 1 = 93
Branch analysis from position: 93
Branch analysis from position: 82
1 jumps found. (Code = 42) Position 1 = 93
Branch analysis from position: 93
Branch analysis from position: 89
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
Branch analysis from position: 94
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 94
Branch analysis from position: 96
1 jumps found. (Code = 42) Position 1 = 104
Branch analysis from position: 104
Branch analysis from position: 96
Branch analysis from position: 100
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 105
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 105
filename:       /in/slG4O
function name:  (null)
number of ops:  107
compiled vars:  !0 = $str, !1 = $output, !2 = $cat, !3 = $options, !4 = $apiLiveOptions, !5 = $value, !6 = $key, !7 = $array, !8 = $apiLiveArray, !9 = $v, !10 = $k, !11 = $newArray, !12 = $column, !13 = $row, !14 = $c, !15 = $r
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   ASSIGN                                                   !0, 'discount_rule%5B0%5D%5Bservice_no%5D%5B0%5D%5Bservice_nos%5D%3D100'
   32     1        INIT_FCALL                                               'parse_str'
          2        SEND_VAR                                                 !0
          3        SEND_REF                                                 !1
          4        DO_ICALL                                                 
   33     5        ASSIGN                                                   !2, 'admintools-api'
   34     6        ASSIGN                                                   !3, <array>
   35     7        ASSIGN                                                   !4, <array>
   37     8      > FE_RESET_R                                       $21     !1, ->105
          9    > > FE_FETCH_R                                       ~22     $21, !5, ->105
         10    >   ASSIGN                                                   !6, ~22
   38    11        TYPE_CHECK                                  128          !5
         12      > JMPZ                                                     ~24, ->100
   39    13    >   ISSET_ISEMPTY_DIM_OBJ                         1  ~25     !5, !6
         14        BOOL_NOT                                         ~26     ~25
         15      > JMPZ                                                     ~26, ->21
   40    16    >   ASSIGN_DIM                                               !3, !6
         17        OP_DATA                                                  !5
   41    18        ASSIGN_DIM                                               !4, !6
         19        OP_DATA                                                  !5
         20      > JMP                                                      ->99
   43    21    >   ASSIGN                                                   !7, <array>
   44    22        ASSIGN                                                   !8, <array>
   45    23      > FE_RESET_R                                       $31     !5, ->96
         24    > > FE_FETCH_R                                       ~32     $31, !9, ->96
         25    >   ASSIGN                                                   !10, ~32
   46    26        ISSET_ISEMPTY_DIM_OBJ                         1  ~34     !9, !10
         27        BOOL_NOT                                         ~35     ~34
         28      > JMPZ                                                     ~35, ->38
   47    29    >   FETCH_DIM_R                                      ~37     !5, !10
         30        ASSIGN_DIM                                               !7
         31        OP_DATA                                                  ~37
   48    32        FETCH_DIM_R                                      ~39     !5, !10
         33        ASSIGN_DIM                                               !8
         34        OP_DATA                                                  ~39
   49    35        ASSIGN_DIM                                               !3, !6
         36        OP_DATA                                                  !7
         37      > JMP                                                      ->95
   51    38    >   INIT_FCALL                                               'array_filter'
         39        SEND_VAR                                                 !9
         40        SEND_VAL                                                 'isEmptyArray'
         41        DO_ICALL                                         $41     
         42        ASSIGN                                                   !11, $41
   52    43        ASSIGN_DIM                                               !8, !10
         44        OP_DATA                                                  !11
   53    45      > FE_RESET_R                                       $44     !11, ->94
         46    > > FE_FETCH_R                                       ~45     $44, !12, ->94
         47    >   ASSIGN                                                   !13, ~45
   54    48        TYPE_CHECK                                  128          !12
         49      > JMPZ                                                     ~47, ->73
   55    50    > > FE_RESET_R                                       $48     !12, ->71
         51    > > FE_FETCH_R                                       ~49     $48, !14, ->71
         52    >   ASSIGN                                                   !15, ~49
   56    53        IS_EQUAL                                                 !2, 'admintools-api'
         54      > JMPZ                                                     ~51, ->67
   57    55    >   INIT_FCALL                                               'var_dump'
         56        SEND_VAR                                                 !14
         57        DO_ICALL                                                 
   58    58        INIT_FCALL                                               'var_dump'
         59        INIT_FCALL                                               'array_values'
         60        SEND_VAR                                                 !14
         61        DO_ICALL                                         $53     
         62        FETCH_DIM_R                                      ~54     $53, 0
         63        COUNT                                            ~55     ~54
         64        SEND_VAL                                                 ~55
         65        DO_ICALL                                                 
         66      > JMP                                                      ->70
   62    67    >   FETCH_DIM_W                                      $57     !3, !13
         68        ASSIGN_DIM                                               $57, !15
         69        OP_DATA                                                  !14
   55    70    > > JMP                                                      ->51
         71    >   FE_FREE                                                  $48
         72      > JMP                                                      ->93
   66    73    >   IS_EQUAL                                                 !2, 'admintools-api'
         74      > JMPZ                                                     ~59, ->89
   67    75    >   IS_EQUAL                                                 !6, !13
         76      > JMPZ                                                     ~60, ->82
         77    >   FETCH_DIM_W                                      $61     !3, !6
         78        ASSIGN_DIM                                       ~62     $61, !10
         79        OP_DATA                                                  !12
         80        QM_ASSIGN                                        ~63     ~62
         81      > JMP                                                      ->87
         82    >   FETCH_DIM_W                                      $64     !3, !6
         83        FETCH_DIM_W                                      $65     $64, !10
         84        ASSIGN_DIM                                       ~66     $65, !13
         85        OP_DATA                                                  !12
         86        QM_ASSIGN                                        ~63     ~66
         87    >   FREE                                                     ~63
         88      > JMP                                                      ->93
   69    89    >   ASSIGN_DIM                                               !7, !10
         90        OP_DATA                                                  !12
   70    91        ASSIGN_DIM                                               !3, !13
         92        OP_DATA                                                  !7
   53    93    > > JMP                                                      ->46
         94    >   FE_FREE                                                  $44
   45    95    > > JMP                                                      ->24
         96    >   FE_FREE                                                  $31
   76    97        ASSIGN_DIM                                               !4, !6
         98        OP_DATA                                                  !8
         99    > > JMP                                                      ->104
   79   100    >   ASSIGN_DIM                                               !3, !6
        101        OP_DATA                                                  !5
   80   102        ASSIGN_DIM                                               !4, !6
        103        OP_DATA                                                  !5
   37   104    > > JMP                                                      ->9
        105    >   FE_FREE                                                  $21
   86   106      > RETURN                                                   1

Function isemptyarray:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 8
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 47) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 15
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/slG4O
function name:  isEmptyArray
number of ops:  17
compiled vars:  !0 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        TYPE_CHECK                                  128          !0
          2      > JMPZ                                                     ~1, ->8
    4     3    >   INIT_FCALL                                               'array_filter'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 'isEmptyArray'
          6        DO_ICALL                                         $2      
          7      > RETURN                                                   $2
    7     8    >   ISSET_ISEMPTY_CV                                 ~3      !0
          9        BOOL_NOT                                         ~4      ~3
         10      > JMPNZ_EX                                         ~4      ~4, ->13
         11    >   IS_IDENTICAL                                     ~5      !0, '0'
         12        BOOL                                             ~4      ~5
         13    > > JMPZ                                                     ~4, ->15
    8    14    > > RETURN                                                   <true>
   11    15    > > RETURN                                                   <false>
   12    16*     > RETURN                                                   null

End of function isemptyarray

Function removeemptyarrays:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/slG4O
function name:  removeEmptyArrays
number of ops:  8
compiled vars:  !0 = $array, !1 = $filteredArray
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   16     1        INIT_FCALL                                               'array_filter'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 'isEmptyArray'
          4        DO_ICALL                                         $2      
          5        ASSIGN                                                   !1, $2
   17     6      > RETURN                                                   !1
   18     7*     > RETURN                                                   null

End of function removeemptyarrays

Function ismultidimensional:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 11
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 11
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
Branch analysis from position: 12
filename:       /in/slG4O
function name:  isMultiDimensional
number of ops:  14
compiled vars:  !0 = $array, !1 = $value, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   22     1        TYPE_CHECK                                  128          !0
          2      > JMPZ                                                     ~3, ->12
   23     3    > > FE_RESET_R                                       $4      !0, ->11
          4    > > FE_FETCH_R                                       ~5      $4, !1, ->11
          5    >   ASSIGN                                                   !2, ~5
   24     6        TYPE_CHECK                                  128          !1
          7      > JMPZ                                                     ~7, ->10
   25     8    >   FE_FREE                                                  $4
          9      > RETURN                                                   <true>
   23    10    > > JMP                                                      ->4
         11    >   FE_FREE                                                  $4
   29    12    > > RETURN                                                   <false>
   30    13*     > RETURN                                                   null

End of function ismultidimensional

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.6 ms | 1412 KiB | 21 Q