xml simplexml_load_file url info array foreach xml- result as key resu

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
$xml = simplexml_load_file($url);
$info = array();
foreach ($xml->result as $key => $result) {
if($key == $oldkey){
$i++;}else{$i=0;}
$oldkey = $key;
if($result->children()){
foreach ($result as $key1=>$value1){
if($key1 == $oldkey1){
$a++;}else{$a=0;}
$oldkey1 = $key1;
if($value1->children()){
foreach ($value1 as $key2=>$value2){
if($key2 == $oldkey2){
$b++;}else{$b=0;}
$oldkey2 = $key2;
if($value2->children()){
foreach ($value2 as $key3=>$value3){
if($key3 == $oldkey3){
$c++;}else{$c=0;}
$oldkey3 = $key3;
if($value3->children()){
foreach ($value3 as $key4=>$value4){
$info["$key"]["$i"]["$key1"]["$a"]["$key2"]["$b"]["$key3"]["$c"]["$key4"]=$value4."\n";
}
}else{
$info["$key"]["$i"]["$key1"]["$a"]["$key2"]["$b"]["$key3"]["$c"]=$value3."\n";
}
}
}else{
$info["$key"]["$i"]["$key1"]["$a"]["$key2"]["$b"]=$value2."\n";
}
}
}else{
$info["$key"]["$i"]["$key1"]["$a"]=$value1."\n";
}
}
}else{$info["$key"]["$i"]= $result."\n" ;
}
}