Convert the array data to SimpleXMLElement object
Definition at line 14 of file ConvertArray.php.
◆ assocToXml()
assocToXml |
( |
array |
$array, |
|
|
|
$rootName = '_' |
|
) |
| |
Transform an assoc array to \SimpleXMLElement object Array has some limitations. Appropriate exceptions will be thrown
- Parameters
-
array | $array | |
string | $rootName | |
- Returns
- \SimpleXMLElement
- Exceptions
-
Definition at line 25 of file ConvertArray.php.
27 if (empty($rootName) || is_numeric($rootName)) {
28 throw new LocalizedException(
30 "The root element can't be empty or use numbers. Change the element and try again." 36 <?xml version=
'1.0' encoding=
'UTF-8' standalone=
'yes'?>
37 <$rootName></$rootName>
39 $xml = new \SimpleXMLElement($xmlStr);
40 foreach (array_keys($array) as $key) {
41 if (is_numeric($key)) {
42 throw new LocalizedException(
43 new \
Magento\Framework\Phrase(
'An error occurred. Use non-numeric array root keys and try again.')
47 return self::_assocToXml($array, $rootName, $xml);
◆ toFlatArray()
static toFlatArray |
( |
|
$data | ) |
|
|
static |
Convert nested array into flat array.
- Parameters
-
- Returns
- array
Definition at line 56 of file ConvertArray.php.
static toFlatArray($data)
The documentation for this class was generated from the following file: