I couldn't find this problem on the Q&A section, so I'm wondering how to flatten a multi (x)-dimensional array into one array? We do not know the structure of the array up front, but ultimately want it to end up as one array containing only elements that contain data. Rather than having this array:
I would like to make the above array (printed using Data::Dumper) into the following:$VAR1 = [ '', '' ]; $VAR1 = [ '', '' ]; $VAR1 = [ 'funct1', '', '' ]; $VAR1 = [ '', '' ]; $VAR1 = [ '', [ '', [ 'funct2a', 'funct2b', '' ], '' ], '' ]; $VAR1 = 'funct3'; $VAR1 = 'funct4'; $VAR1 = 'funct5'; $VAR1 = 'funct6'; $VAR1 = 'funct7';
$VAR1 = 'funct1'; $VAR1 = 'funct2a'; $VAR1 = 'funct2b'; $VAR1 = 'funct3'; $VAR1 = 'funct4'; $VAR1 = 'funct5'; $VAR1 = 'funct6'; $VAR1 = 'funct7';
Is this possible? Of course, I just don't know how...
In reply to How to flatten an x-dimensional array? by Incognito
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |