M
M
Maxim Lesnikov2014-04-07 09:59:44
Arrays
Maxim Lesnikov, 2014-04-07 09:59:44

multidimensional xml array

There is a PHP Code that pulls information from infoblocks (Bitrix) and converts it all into an xml file.
There is a code that pulls out pictures, and they turn out like this:

<images>
www.***.ru/upload/iblock/f78/cqm yrtlx-2.jpg, www.***.ru/upload/iblock/3c8/01_big.jpg, 
</images>

And it needs to be like this:
<images primary="1">
<image>www.***.ru/upload/iblock/f78/cqm yrtlx-2.jpg</image>
<image>www.***.ru/upload/iblock/3c8/01_big.jpg</image>
</images>

The PHP code is currently:
$db_props = CIBlockElement::GetProperty("18", $arFields["ID"], array("sort" => "asc"), array("CODE"=>"MORE_PHOTO"));
    $razd = "";
    $photo = "";
    while($ar_props = $db_props->Fetch())
    {	
      $rsFile = CFile::GetByID($ar_props["VALUE"]);
      $arFile = $rsFile->Fetch();
            $arImagesPath = CFile::GetPath($ar_props["VALUE"]);
            $domainname = "www.***.ru";
      //$photo = $photo.$razd.$arFile["FILE_NAME"];
            $photo = $photo.$razd.$domainname.$arImagesPath;
      //print_r($domainname.$arImagesPath);print_r(" ");
      $razd = ", ";
      //$arrImages[$arElement["ID"]][] = $arFile;
      //print_r($ar_props);
    }
    $fieldsToExport[$i]["images"] = $photo;

    $arrayToExport = array_merge($arrayToExport, $fieldsToExport);

    $i++;
  }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question