PHP
- 3 ответа
- 0 вопросов
3
Вклад в тег
<?php
$feedObj = simplexml_load_file("type.xml");
$arr = [];
foreach ($feedObj as $item):
foreach($item->bonus as $bonus):
$arr[(string)$item["name"]][(string)$bonus["id"]] = (string)$bonus["value"];
endforeach;
endforeach;
echo "<pre>";
var_dump($arr);
echo "</pre>";
array(2) {
["Зачарованные сапоги"]=>
array(9) {
[99]=>
string(9) "20.000000"
[256]=>
string(8) "0.650000"
[257]=>
string(8) "0.490000"
[2]=>
string(10) "210.000000"
[244]=>
string(8) "0.600000"
[248]=>
string(8) "0.520000"
[249]=>
string(8) "0.410000"
[304]=>
string(8) "1.000000"
[0]=>
string(8) "0.000000"
}
["Зачарованные поножи"]=>
array(9) {
[99]=>
string(9) "21.000000"
[256]=>
string(8) "0.580000"
[257]=>
string(8) "0.510000"
[2]=>
string(10) "410.000000"
[248]=>
string(8) "0.650000"
[249]=>
string(8) "0.550000"
[240]=>
string(8) "0.020000"
[304]=>
string(8) "1.000000"
[0]=>
string(8) "0.000000"
}
}