note 55287 deleted from function.xml-parse-into-struct by sniper
| From: | sniper@php.net | Date: | Mon, 28 Nov 2005 13:09:36 +0000 |
| Subject: | note 55287 deleted from function.xml-parse-into-struct by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-99242@lists.php.net to get a copy of this message | ||
Note Submitter: cfb at cafer dot org
----
Generating simple XML from array hash
<?php
function xmlFromArray($a, $root = 0) {
$temp = "";
foreach ($a as $key => $value) {
if (is_array($value)) {
$temp .= sprintf("<%s>", $key);
$temp .= xmlFromArray($value, 1);
$temp .= sprintf("</%s>", $key);
} else {
$temp .= sprintf("<%s>%s</%s>", $key, $value, $key);
}
}
if ($root == 0) {
$temp = "<?xml version=\"1.0\"?>" . $temp;
}
return $temp;
}
?>