Download the PHP package rboonzaijer/php-array-to-xml without Composer
On this page you can find all versions of the php package rboonzaijer/php-array-to-xml. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rboonzaijer/php-array-to-xml
More information about rboonzaijer/php-array-to-xml
Files in rboonzaijer/php-array-to-xml
Package php-array-to-xml
Short Description Convert an array to XML with PHP
License MIT
Homepage https://github.com/rboonzaijer/php-array-to-xml
Informations about the package php-array-to-xml
PhpArrayToXml
Convert an array to XML with PHP
Install
Require the vendor files (these already loaded if you are using something like Symfony or Laravel)
Usage
Basic example:
Output:
Output Format (Prettify)
->setFormatOutput(bool $value = false)
Alias:
->prettify()
is the same as typing:->setFormatOutput(true)
Default:
Usage:
Result:
Custom root name
->setCustomRootName(string $value = 'root')
Result:
Custom tag name
Custom tag names are used when an array has no key names
->setCustomTagName(string $value = 'node')
Default (prettified):
Usage:
Result (prettified):
XML version
->setVersion(string $value = '1.0')
Result (prettified):
XML encoding
->setEncoding(string $value = 'UTF-8')
Result (prettified):
Tag separator
Set the value for the separator that will be used to replace special characters in tag names
->setSeparator(string $value = '_')
Default (prettified):
Usage:
Result (prettified):
Transform tag names
Transform tag names to uppercase/lowercase
->setTransformTags(string $value = null)
Default (prettified):
Usage (lowercase):
Result (prettified):
Usage (uppercase):
Result (prettified):
Usage (uppercase, but with custom tag names, which will not be transformed):
Result (prettified):
Set numeric tag suffix
If this is not null, it appends the numeric array key to the tag name, with the value as separator.
->setNumericTagSuffix(string $value = null)
Default (prettified):
Usage:
Result (prettified):
Cast boolean values
By default boolean values from the array will be cast to the string 'true' or 'false'. You can choose to cast it to any (string) value you like. This method only works on real boolean values, so strings with the value 'true' and 'false' are untouched.
->setCastBooleanValueTrue(string $value = 'true')
->setCastBooleanValueFalse(string $value = 'false')
Default (prettified):
Usage:
Result (prettified):
Cast NULL values
By default null values from the array will have no value in the XML, so the tag looks something like this:
<MyTag/>
. You can choose to cast it to any (string) value you like. This method only works on real 'null' values, so strings with the value'null'
or empty strings''
are untouched.
->setCastNullValue(null|string $value = null)
Default (prettified):
Usage:
Result (prettified):
Development
- DEVELOPMENT.md