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; } $string='client_no=3286868&auth_key=K6htqteKvAFpJE4qaE655hTQRSVN9PGU&rest_call=create_acct_complete_m&billing_group[billing_group_row][0][billing_group_name]=&billing_group[billing_group_row][0][billing_group_description]=&billing_group[billing_group_row][0][client_billing_group_id]=&billing_group[billing_group_row][0][billing_group_idx]=&billing_group[billing_group_row][0][notify_method]=&billing_group[billing_group_row][0][notify_template_group]=&billing_group[billing_group_row][0][statement_template]='; parse_str($string, $output); $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') { if(isMultiDimensional($c) || (array_keys($c)[0] != $row.'s' ) ){ $options[$key][$k][$row][$r]=$c; } else { $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($options); ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 120
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 120
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 115
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 20
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 114
Branch analysis from position: 114
1 jumps found. (Code = 42) Position 1 = 119
Branch analysis from position: 119
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 20
2 jumps found. (Code = 77) Position 1 = 23, Position 2 = 111
Branch analysis from position: 23
2 jumps found. (Code = 78) Position 1 = 24, Position 2 = 111
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 37
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 110
Branch analysis from position: 110
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 37
2 jumps found. (Code = 77) Position 1 = 45, Position 2 = 109
Branch analysis from position: 45
2 jumps found. (Code = 78) Position 1 = 46, Position 2 = 109
Branch analysis from position: 46
2 jumps found. (Code = 43) Position 1 = 49, Position 2 = 88
Branch analysis from position: 49
2 jumps found. (Code = 77) Position 1 = 50, Position 2 = 86
Branch analysis from position: 50
2 jumps found. (Code = 78) Position 1 = 51, Position 2 = 86
Branch analysis from position: 51
2 jumps found. (Code = 43) Position 1 = 54, Position 2 = 82
Branch analysis from position: 54
2 jumps found. (Code = 47) Position 1 = 58, Position 2 = 65
Branch analysis from position: 58
2 jumps found. (Code = 43) Position 1 = 66, Position 2 = 72
Branch analysis from position: 66
1 jumps found. (Code = 42) Position 1 = 81
Branch analysis from position: 81
1 jumps found. (Code = 42) Position 1 = 85
Branch analysis from position: 85
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
Branch analysis from position: 72
1 jumps found. (Code = 42) Position 1 = 85
Branch analysis from position: 85
Branch analysis from position: 65
Branch analysis from position: 82
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
Branch analysis from position: 86
1 jumps found. (Code = 42) Position 1 = 108
Branch analysis from position: 108
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
Branch analysis from position: 86
Branch analysis from position: 88
2 jumps found. (Code = 43) Position 1 = 90, Position 2 = 104
Branch analysis from position: 90
2 jumps found. (Code = 43) Position 1 = 92, Position 2 = 97
Branch analysis from position: 92
1 jumps found. (Code = 42) Position 1 = 102
Branch analysis from position: 102
1 jumps found. (Code = 42) Position 1 = 108
Branch analysis from position: 108
Branch analysis from position: 97
1 jumps found. (Code = 42) Position 1 = 108
Branch analysis from position: 108
Branch analysis from position: 104
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
Branch analysis from position: 109
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 109
Branch analysis from position: 111
1 jumps found. (Code = 42) Position 1 = 119
Branch analysis from position: 119
Branch analysis from position: 111
Branch analysis from position: 115
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 120
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 120
filename:       /in/LZdot
function name:  (null)
number of ops:  125
compiled vars:  !0 = $string, !1 = $output, !2 = $options, !3 = $apiLiveOptions, !4 = $value, !5 = $key, !6 = $array, !7 = $apiLiveArray, !8 = $v, !9 = $k, !10 = $newArray, !11 = $column, !12 = $row, !13 = $c, !14 = $r, !15 = $cat
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   ASSIGN                                                   !0, 'client_no%3D3286868%26auth_key%3DK6htqteKvAFpJE4qaE655hTQRSVN9PGU%26rest_call%3Dcreate_acct_complete_m%26billing_group%5Bbilling_group_row%5D%5B0%5D%5Bbilling_group_name%5D%3D%26billing_group%5Bbilling_group_row%5D%5B0%5D%5Bbilling_group_description%5D%3D%26billing_group%5Bbilling_group_row%5D%5B0%5D%5Bclient_billing_group_id%5D%3D%26billing_group%5Bbilling_group_row%5D%5B0%5D%5Bbilling_group_idx%5D%3D%26billing_group%5Bbilling_group_row%5D%5B0%5D%5Bnotify_method%5D%3D%26billing_group%5Bbilling_group_row%5D%5B0%5D%5Bnotify_template_group%5D%3D%26billing_group%5Bbilling_group_row%5D%5B0%5D%5Bstatement_template%5D%3D'
   24     1        INIT_FCALL                                               'parse_str'
          2        SEND_VAR                                                 !0
          3        SEND_REF                                                 !1
          4        DO_ICALL                                                 
   25     5        ASSIGN                                                   !2, <array>
   26     6        ASSIGN                                                   !3, <array>
   28     7      > FE_RESET_R                                       $20     !1, ->120
          8    > > FE_FETCH_R                                       ~21     $20, !4, ->120
          9    >   ASSIGN                                                   !5, ~21
   29    10        TYPE_CHECK                                  128          !4
         11      > JMPZ                                                     ~23, ->115
   30    12    >   ISSET_ISEMPTY_DIM_OBJ                         1  ~24     !4, !5
         13        BOOL_NOT                                         ~25     ~24
         14      > JMPZ                                                     ~25, ->20
   31    15    >   ASSIGN_DIM                                               !2, !5
         16        OP_DATA                                                  !4
   32    17        ASSIGN_DIM                                               !3, !5
         18        OP_DATA                                                  !4
         19      > JMP                                                      ->114
   34    20    >   ASSIGN                                                   !6, <array>
   35    21        ASSIGN                                                   !7, <array>
   36    22      > FE_RESET_R                                       $30     !4, ->111
         23    > > FE_FETCH_R                                       ~31     $30, !8, ->111
         24    >   ASSIGN                                                   !9, ~31
   37    25        ISSET_ISEMPTY_DIM_OBJ                         1  ~33     !8, !9
         26        BOOL_NOT                                         ~34     ~33
         27      > JMPZ                                                     ~34, ->37
   38    28    >   FETCH_DIM_R                                      ~36     !4, !9
         29        ASSIGN_DIM                                               !6
         30        OP_DATA                                                  ~36
   39    31        FETCH_DIM_R                                      ~38     !4, !9
         32        ASSIGN_DIM                                               !7
         33        OP_DATA                                                  ~38
   40    34        ASSIGN_DIM                                               !2, !5
         35        OP_DATA                                                  !6
         36      > JMP                                                      ->110
   42    37    >   INIT_FCALL                                               'array_filter'
         38        SEND_VAR                                                 !8
         39        SEND_VAL                                                 'isEmptyArray'
         40        DO_ICALL                                         $40     
         41        ASSIGN                                                   !10, $40
   43    42        ASSIGN_DIM                                               !7, !9
         43        OP_DATA                                                  !10
   44    44      > FE_RESET_R                                       $43     !10, ->109
         45    > > FE_FETCH_R                                       ~44     $43, !11, ->109
         46    >   ASSIGN                                                   !12, ~44
   45    47        TYPE_CHECK                                  128          !11
         48      > JMPZ                                                     ~46, ->88
   46    49    > > FE_RESET_R                                       $47     !11, ->86
         50    > > FE_FETCH_R                                       ~48     $47, !13, ->86
         51    >   ASSIGN                                                   !14, ~48
   47    52        IS_EQUAL                                                 !15, 'admintools-api'
         53      > JMPZ                                                     ~50, ->82
   48    54    >   INIT_FCALL_BY_NAME                                       'isMultiDimensional'
         55        SEND_VAR_EX                                              !13
         56        DO_FCALL                                      0  $51     
         57      > JMPNZ_EX                                         ~52     $51, ->65
         58    >   INIT_FCALL                                               'array_keys'
         59        SEND_VAR                                                 !13
         60        DO_ICALL                                         $53     
         61        FETCH_DIM_R                                      ~54     $53, 0
         62        CONCAT                                           ~55     !12, 's'
         63        IS_NOT_EQUAL                                     ~56     ~54, ~55
         64        BOOL                                             ~52     ~56
         65    > > JMPZ                                                     ~52, ->72
   49    66    >   FETCH_DIM_W                                      $57     !2, !5
         67        FETCH_DIM_W                                      $58     $57, !9
         68        FETCH_DIM_W                                      $59     $58, !12
         69        ASSIGN_DIM                                               $59, !14
         70        OP_DATA                                                  !13
         71      > JMP                                                      ->81
   51    72    >   INIT_FCALL                                               'array_values'
         73        SEND_VAR                                                 !13
         74        DO_ICALL                                         $65     
         75        FETCH_DIM_R                                      ~66     $65, 0
         76        FETCH_DIM_W                                      $61     !2, !5
         77        FETCH_DIM_W                                      $62     $61, !9
         78        FETCH_DIM_W                                      $63     $62, !12
         79        ASSIGN_DIM                                               $63, !14
         80        OP_DATA                                                  ~66
         81    > > JMP                                                      ->85
   54    82    >   FETCH_DIM_W                                      $67     !2, !12
         83        ASSIGN_DIM                                               $67, !14
         84        OP_DATA                                                  !13
   46    85    > > JMP                                                      ->50
         86    >   FE_FREE                                                  $47
         87      > JMP                                                      ->108
   58    88    >   IS_EQUAL                                                 !15, 'admintools-api'
         89      > JMPZ                                                     ~69, ->104
   59    90    >   IS_EQUAL                                                 !5, !12
         91      > JMPZ                                                     ~70, ->97
         92    >   FETCH_DIM_W                                      $71     !2, !5
         93        ASSIGN_DIM                                       ~72     $71, !9
         94        OP_DATA                                                  !11
         95        QM_ASSIGN                                        ~73     ~72
         96      > JMP                                                      ->102
         97    >   FETCH_DIM_W                                      $74     !2, !5
         98        FETCH_DIM_W                                      $75     $74, !9
         99        ASSIGN_DIM                                       ~76     $75, !12
        100        OP_DATA                                                  !11
        101        QM_ASSIGN                                        ~73     ~76
        102    >   FREE                                                     ~73
        103      > JMP                                                      ->108
   61   104    >   ASSIGN_DIM                                               !6, !9
        105        OP_DATA                                                  !11
   62   106        ASSIGN_DIM                                               !2, !12
        107        OP_DATA                                                  !6
   44   108    > > JMP                                                      ->45
        109    >   FE_FREE                                                  $43
   36   110    > > JMP                                                      ->23
        111    >   FE_FREE                                                  $30
   68   112        ASSIGN_DIM                                               !3, !5
        113        OP_DATA                                                  !7
        114    > > JMP                                                      ->119
   71   115    >   ASSIGN_DIM                                               !2, !5
        116        OP_DATA                                                  !4
   72   117        ASSIGN_DIM                                               !3, !5
        118        OP_DATA                                                  !4
   28   119    > > JMP                                                      ->8
        120    >   FE_FREE                                                  $20
   76   121        INIT_FCALL                                               'var_dump'
        122        SEND_VAR                                                 !2
        123        DO_ICALL                                                 
   77   124      > 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/LZdot
function name:  isEmptyArray
number of ops:  17
compiled vars:  !0 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        TYPE_CHECK                                  128          !0
          2      > JMPZ                                                     ~1, ->8
    5     3    >   INIT_FCALL                                               'array_filter'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 'isEmptyArray'
          6        DO_ICALL                                         $2      
          7      > RETURN                                                   $2
    8     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
    9    14    > > RETURN                                                   <true>
   12    15    > > RETURN                                                   <false>
   13    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/LZdot
function name:  removeEmptyArrays
number of ops:  8
compiled vars:  !0 = $array, !1 = $filteredArray
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   17     1        INIT_FCALL                                               'array_filter'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 'isEmptyArray'
          4        DO_ICALL                                         $2      
          5        ASSIGN                                                   !1, $2
   18     6      > RETURN                                                   !1
   19     7*     > RETURN                                                   null

End of function removeemptyarrays

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.85 ms | 1412 KiB | 23 Q