es ist keine einfache Erklärung für mich, aber ich versuche es. Ich muss ein mehrdimensionales Array erstellen die gleiche Array Verschmelzung von Schlüsseln,Merge Multi-Array mit Tasten
Mein Haupt Array ist:
[A] => Array
(
[A1] =>
[A2] =>
[A3] =>
[A4] =>
[A5] =>
)
[A1] => Array
(
[A1a] =>
[A1b] =>
[A1c] =>
[A1d] =>
[A1f] =>
)
[A1a] => Array
(
[A1a1] =>
[A1a2] =>
[A1a3] =>
[A1a4] =>
[A1a5] =>
)
[A1a1] => value
Also, was ich brauche, ist:
[A] => Array
(
[A1] => Array
(
[A1a] => Array
(
[A1a1] => value
)
)
Dies ist, was ich versuchte, :
$final = array();
foreach($content as $key => $value){
$final[$key] = glue($content, $key);
}
function glue($content, $i){
$data = '';
if(isset($content[$i])) {
$data = $content[$i];
if(is_array($data)){
foreach($data as $cl => $value) {
$data[$cl] = glue($content, $cl);
}
}
}
return $data;
}
Mit, dass ich habe, wie ich will, aber das Ende-Tasten sind leer:
[A14] => Array
(
[A14a] => Array
(
[7461*] =>
)
[A14b] => Array
(
[A14b1] => Array
(
[A14b11] => Array
(
[7600*] =>
[7601*] =>
)
[A14b12] => Array
(
[7602*] =>
[7603*] =>
)
)
Zeigen Sie, was Sie –
foreach ($ contents wie $ key => $ value) { \t $ contents [$ cl] = Kleber ($ contents, $ cl) versucht haben; } \t Funktion Kleber ($ Inhalt, $ i) { \t $ data = ''; \t \t if (isset ($ Inhalt [$ i])) { \t \t \t $ data = $ Inhalt [$ i]; \t \t \t if (is_array ($ data)) { \t \t \t \t foreach ($ data wie $ cl => $ value) { \t \t \t \t \t $ data [$ cl] = Kleber ($ contents, $ cl); \t \t \t \t} \t \t \t} \t \t} \t \t \t \t return $ Daten; \t Dies fügt alle Arrays in seine "Eltern", aber das Ende Array ist leer, verlieren Sie die Werte ,,, –