vansari / EnvReader

PHP Environment Reader
MIT License
3 stars 0 forks source link

Parse Multidimensional Arrays #9

Open vansari opened 1 year ago

vansari commented 1 year ago

At the Moment in Issue #5 we can parse only primitive arrays It would be helpful if we can parse multidimensional arrays.

Test cases:

'Array with subarrays' => [
    'input‘ => '[a,b,c,[123,23,2,[abc,def]], d,e,f]‘,
    'expected‘ => ['a', 'b', 'c', [123, 23, 2, ['abc', 'def']], 'd', 'e', ‚f‘]
],
'Array with subarrays #2' => [
    'input‘ => '[[123,23,2,[abc,def]], a,b,c,d,e,f]‘,
    'expected‘ => [[123, 23, 2, ['abc', 'def']], 'a', 'b', 'c', 'd', 'e', ‚f‘]
],
'Array with subarrays #3' => [
    'input‘ => '[[123,23,2], a,b,c,d,e,f,[abc,def]]‘,
    'expected‘ => [[123, 23, 2], 'a', 'b', 'c', 'd', 'e', 'f', ['abc', 'def‘]]
]
vansari commented 1 year ago

By the way: Is it really necessary to parse multidimensional Array without keys? Is it not better to use the feature JSON for this?