dev-master
9999999-dev
MIT
The Requires
- php >=5.4
- yagmikita/std-signatures dev-master
by Gopkalo Nikita
xml library array utils utilities lib array2xml
Wallogit.com
2017 © Pedro Peláez
<?php
require_once realpath(__DIR__ . '/../vendor/autoload.php');
use \ArrayUtils\Array2Xml;
$a = [
'root' => [
'@attributes' => [
'attr1' => '1',
],
],
];
$a2x = new Array2Xml($a);
echo $a2x->conv();
Output:
<?xml version="1.0" encoding="UTF-8"?> <root attr1="1"/>
<?php
$a = [
'root' => [
'message' => [
'@content' => 'This is text content',
],
],
];
$a2x = new Array2Xml($a);
echo $a2x->conv();
Output:
<?xml version="1.0" encoding="UTF-8"?> <root> <message>This is text content</message> </root>
<?php
$a = [
'root' => [
'person' => [
'gender' => 'male',
'age' => '26',
'name' => 'Александр',
],
],
];
$a2x = new Array2Xml($a);
echo $a2x->conv();
Output:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<person>
<gender>male</gender>
<age>26</age>
<name>Александр</name>
</person>
</root>
<?php
$a = [
'root' => [
'@attributes' => [
'type' => 'test_type',
'id' => 'test_id',
'text' => 'русский текст'
],
'main' => [
'@attributes' => [
'uid' => 'u201j3a0828ki3si0',
'src' => 'open',
'start' => '12423511247',
'stop' => '12423991978',
'adtp' => 'dbt',
'clid' => '100500',
],
'attr' => [
[
'@attributes' => [
'code' => '1',
'val' => '11',
],
],
[
'@attributes' => [
'code' => '2',
'val' => '12',
],
],
],
'history' => [
[
'@attributes' => [
'at1' => '1',
'at2' => '2',
'at3' => '3',
'at4' => 'test',
],
],
],
'person' => [
'gender' => [
'@content' => 'male'
],
'age' => [
'@content' => 26,
],
'name' => [
'@content' => 'Александр'
],
],
],
],
];
$a2x = new Array2Xml($a);
echo $a2x->conv();
Output:
<?xml version="1.0" encoding="UTF-8"?>
<root type="test_type" id="test_id" text="русский текст">
<main uid="u201j3a0828ki3si0" src="open" start="12423511247" stop="12423991978" adtp="dbt" clid="100500">
<attr code="1" val="11"/>
<attr code="2" val="12"/>
<history at1="1" at2="2" at3="3" at4="test"/>
<person>
<gender>male</gender>
<age>26</age>
<name>Александр</name>
</person>
</main>
</root>
MIT
xml library array utils utilities lib array2xml