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

End of function removeemptyparameter

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/QL6d0
function name:  isMultiDimensional
number of ops:  14
compiled vars:  !0 = $array, !1 = $value, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   RECV                                             !0      
   48     1        TYPE_CHECK                                  128          !0
          2      > JMPZ                                                     ~3, ->12
   49     3    > > FE_RESET_R                                       $4      !0, ->11
          4    > > FE_FETCH_R                                       ~5      $4, !1, ->11
          5    >   ASSIGN                                                   !2, ~5
   50     6        TYPE_CHECK                                  128          !1
          7      > JMPZ                                                     ~7, ->10
   51     8    >   FE_FREE                                                  $4
          9      > RETURN                                                   <true>
   49    10    > > JMP                                                      ->4
         11    >   FE_FREE                                                  $4
   55    12    > > RETURN                                                   <false>
   56    13*     > RETURN                                                   null

End of function ismultidimensional

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.13 ms | 1423 KiB | 26 Q