Answer the question
In order to leave comments, you need to log in
How to select an element from each end section in a PHP array and output it?
Good afternoon. There is a page 93.90.220.244/get/treolan_cataloglist.php outputting a catalog array with the structure:
- Раздел [category]
- Порядковый номер раздела в массиве [0...n]
- Подраздел с его вытекающими аттрибутами [category]
Если имеются ещё подразделы, то структура повторяется
...
В окончательном подразделе выводятся товары в [position]
- Подрядковый номер товаара в массиве [0...n]
- Атрибуты [@attributes]
...
Артикул в атрибутах [articul]
...
<pre>
<?php
ini_set("memory_limit", "1024M");
$soapClientParams = array('connection_timeout' => 300);
$soapClient = new
SoapClient("***",
$soapClientParams);
try {
$param = array(
'Login' => '***',
'password' => '***',
'category' => '',
'vendorid' => 0,
'keywords' => '',
'criterion' => 0,
'inArticul' => 0,
'inName' => 0,
'inMark' => 0,
'ShowNc' => 0);
$info = $soapClient->__call("GenCatalogV2", $param);
$arResult = ($info['Result']);
$xml = simplexml_load_string($arResult);
$json = json_encode($xml);
$xmlArr = json_decode($json, true);
print_r($xmlArr);
/*foreach ($xmlArr['category'] as $i => $section) {
foreach ($section['category'] as $i => $subsection) {
foreach ($subsection['category'] as $i => $subsubsection) {
print_r($subsubsection);
}
}
}*/
}
catch (SoapFault $fault) {
print("Sorry, WS returned the following ERROR:
".$fault->faultcode."-".$fault->faultstring);
}
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question