S
S
Sp1keazyYT2019-05-04 14:15:11
PHP
Sp1keazyYT, 2019-05-04 14:15:11

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]
              ...

e2735756d8.png
If you look at the array, you can see that in each of course [category] sub-sub-section there is a [position]
a74b0f64cd.png
section. attributes [@attributes] that have [articul].
The task is to loop through the entire array from all the [position] elements and display the [articul] list.
How can this be done?
Here is the page code with the output of the array:
<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

1 answer(s)
L
Lazy @BojackHorseman PHP, 2019-05-04
@Sp1keazyYT

recursion

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question