MilkeyWay
Постоялец
- Регистрация
- 11 Июл 2011
- Сообщения
- 142
- Реакции
- 10
- Автор темы
- #1
Всем привет!
Ребят,помогите дособрать данные в массив из XML,у меня произошел клин...походу утечка памяти...возможно в голове моей))
или получаю такое в логах:
xml:
Объясните на пальцах,что не так делаю?(как картинки закинуть в массив,с учетом type?)
Ребят,помогите дособрать данные в массив из XML,у меня произошел клин...походу утечка памяти...возможно в голове моей))
Код:
$xml = new SimpleXMLElement($dat->xml,LIBXML_NOCDATA);
$data = array();
$img = array();
$y = 0;
foreach ($xml as $item) {
$x = 0;
foreach ($item->images->item as $i) { //тут происходит касяк,либо памяти не хватает(выделил 6гб),либо времени не хватает на обработку (1мин),если больше времени,то все зависает
$q = (string) $i->attributes()->type;
$img[$y][$q][$x] = $i;
$x++;
}
$y++;
$data[] = array(
'product_id' => (int) $item->attributes()->id,
'images' => $img, //проблема с добавлением картинок в массив
'name' => (string) $item->name,
'price_retail' => (float) $item->attributes()->price_retail,
'price_wholesale' => (float) $item->attributes()->price_wholesale,
'price_retail_stock' => (float) $item->attributes()->price_retail_stock,
'price_wholesale_stock' => (float) $item->attributes()->price_wholesale_stock,
'date_change' => (string) $item->attributes()->date_change,
'datetime_release' => (string) $item->attributes()->datetime_release,
'archive' => (int) $item->attributes()->archive,
'publication' => (int) $item->attributes()->publication,
'available' => (int) $item->attributes()->available,
'release' => (int) $item->attributes()->release,
'description' => (string) $item->description
);
}
или получаю такое в логах:
Код:
child pid 12177 exit signal Segmentation fault (11), possible coredump in /etc/apache2
xml:
Код:
[xml] => <?xml version="1.0" encoding="UTF-8"?><products><item id="407" date_change="2016-10-24 18:20:43" datetime_release="2014-09-19 00:00:00" price_retail="100" price_wholesale="50" price_retail_stock="0" price_wholesale_stock="0" release="1" archive="0" publication="1" available="1">
<name><![CDATA[название]]></name>
<name_eng><![CDATA[]]></name_eng>
<description><![CDATA[Описание]]></description>
<images>
<item type="screenshot"><![CDATA[0.jpg]]></item>
<item type="screenshot"><![CDATA[1.jpg]]></item>
<item type="screenshot"><![CDATA[2.jpg]]></item>
<item type="screenshot"><![CDATA[3.jpg]]></item>
<item type="screenshot"><![CDATA[4.jpg]]></item>
<item type="screenshot"><![CDATA[5.jpg]]></item>
<item type="main"><![CDATA[6.jpg]]></item>
</images>
Объясните на пальцах,что не так делаю?(как картинки закинуть в массив,с учетом type?)
Последнее редактирование: