I got a multidimensional array with X number of .... dimensions? Example of my array:
Array
(
[system] => Array
(
[step_x_y] => Array
(
[0] => Schnitt %1 von %2
[1] => Trin %1 af %2
[2] => Step %1 of %2
)
[type] => Array
(
[0] => Typ
[1] => Type
[2] => Type
)
[next_button] => Array
(
[0] => Aktualisieren
[1] => Opdater
[2] => Update
)
[account.php] => Array
(
[h1] => Array
(
[0] => Kontoeinstellungen
[1] => Konto Indstillinger
[2] => Account Settings
)
[fields_required] => Array
(
[0] => Alle Felder, außer die Geschäftsinformation, müssen ausgefüllt werden
[1] => Alle felter er obligatoriske, dog ikke virksomhedsinfo
[2] => All fields required
)
[mounting] => Array
(
[no] => Array
(
[text] => Array
(
[0] => Keine
[1] => Ingen
[2] => Nothing
)
[more_text] => Array
(
[0] => Keine Befestigung
[1] => Ingen befæstelser
[2] => No mounting
)
)
[CFL] => Array
(
[text] => Array
(
[0] => Frontflansch (CLF)
[1] => Front Flange
[2] => Front Flange
)
[more_text] => Array
(
[0] => Frontflansch zum Schweißen an dem Zylinderrohr
[1] => Front flange til påsvejsning på cylinder rør
[2] => Front Flange to be welded on cylinder tube
)
) ....
I'm trying to convert that array, into this "flat" format: (# and the array keys that follows has to be included too)
# system > step_x_y
(DE) Schnitt %1 von %2
(DK) Trin %1 af %2
(EN) Step %1 of %2
# system > type
(DE) Typ
(DK) Type
(EN) Type
# system > next_button
(DE) Aktualisieren
(DK) Opdater
(EN) Update
I use this code, to output all values, one value per line:
$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($merged_array));
foreach($it as $v) {
echo $v, "<br>";
}
A couple of problems:
Not sure how to display the "row of keys" above the values.
[0][1][2] has to replaced with country codes, 0=DE, 1=DK, 2=EN.
Something like this:
# system > step_x_y
(DE) Schnitt %1 von %2
(DK) Trin %1 af %2
(EN) Step %1 of %2
# system > type
(DE) Typ
(DK) Type
(EN) Type
# system > next_button
(DE) Aktualisieren
(DK) Opdater
(EN) Update
Hope one of you might be able to help me out :)
UPDATE:
I changed some of the code as suggested:
foreach ($it as $k => $v) {
if($k == 0)
$cc = '<br>(DE)';
elseif($k == 1)
$cc = '(DK)';
elseif($k == 2)
$cc = '(EN)';
else
$cc = '-';
echo $cc, $v, "<br>";
}
This is the output I recieve now:
(DE) Schnitt %1 von %2
(DK) Trin %1 af %2
(EN) Step %1 of %2
(DE) Typ
(DK) Type
(EN) Type
(DE) Aktualisieren
(DK) Opdater
(EN) Update
Just need to add "keys" above each "section" of values. This to see where the text is located in the array (it's huge).
# system > step_x_y
(DE) Schnitt %1 von %2
(DK) Trin %1 af %2
(EN) Step %1 of %2
# system > type
(DE) Typ
(DK) Type
(EN) Type