Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
framework
Convert
Xml.php
Go to the documentation of this file.
1
<?php
6
namespace
Magento\Framework\Convert
;
7
11
class
Xml
12
{
20
public
function
xmlToAssoc
(\SimpleXMLElement $xml)
21
{
22
$array = [];
23
foreach
($xml as $key =>
$value
) {
24
if
(isset(
$value
->{$key})) {
25
$i
= 0;
26
foreach
(
$value
->{$key} as $v) {
27
$array[$key][
$i
++] = (string)$v;
28
}
29
}
else
{
30
// try to transform it into string value, trimming spaces between elements
31
$array[$key] = trim((
string
)
$value
);
32
if
(empty($array[$key]) && !empty(
$value
)) {
33
$array[$key] = $this->
xmlToAssoc
(
$value
);
34
}
else
{
35
// untrim strings values
36
$array[$key] = (string)
$value
;
37
}
38
}
39
}
40
return
$array;
41
}
42
}
$value
$value
Definition:
gender.phtml:16
Magento\Framework\Convert
Definition:
ConvertArray.php:7
Magento\Framework\Convert\Xml
Definition:
Xml.php:11
Magento\Framework\Convert\Xml\xmlToAssoc
xmlToAssoc(\SimpleXMLElement $xml)
Definition:
Xml.php:20
$i
$i
Definition:
gallery.phtml:31