JSON Builder - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of JSON Builder.php
- <?php
- $xml = new SimpleXMLElement('<xml/>');
- for ($i = 1; $i <= 8; ++$i) {
- $track = $xml->addChild('track');
- $track->addChild('path', "song$i.mp3");
- $track->addChild('title', "Track $i - Track Title");
- }
- $xml_content = formatXml($xml);
- print( $xml_content );
- function formatXml($simpleXMLElement)
- {
- $xmlDocument = new DOMDocument('1.0');
- $xmlDocument->preserveWhiteSpace = false;
- $xmlDocument->formatOutput = true;
- $xmlDocument->loadXML($simpleXMLElement->asXML());
- return $xmlDocument->saveXML();
- }
File Description
- JSON Builder
- PHP Code
- 18 Oct-2019
- 561 Bytes
You can Share it:
Latest PHP Pastes