aboutsummaryrefslogtreecommitdiffstats
path: root/include/text.php
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-08-11 17:02:52 -0700
committerredmatrix <git@macgirvin.com>2016-08-11 17:02:52 -0700
commit3ba4b2c1c1ffa8275337857e10c250b338e15170 (patch)
tree17fad3ad9776e5ac823671af250ddaef9b33a784 /include/text.php
parente985436b3be0a6c0cdb3de57c61de16a25cc0de5 (diff)
downloadvolse-hubzilla-3ba4b2c1c1ffa8275337857e10c250b338e15170.tar.gz
volse-hubzilla-3ba4b2c1c1ffa8275337857e10c250b338e15170.tar.bz2
volse-hubzilla-3ba4b2c1c1ffa8275337857e10c250b338e15170.zip
A bit of api cleanup. Don't get excited. This is like a 0.005% cleanup but you have to start somewhere.
Diffstat (limited to 'include/text.php')
-rw-r--r--include/text.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/include/text.php b/include/text.php
index ac210b336..a2a6d918b 100644
--- a/include/text.php
+++ b/include/text.php
@@ -2975,3 +2975,38 @@ function text_highlight($s,$lang) {
return('<code>' . $o . '</code>');
}
+// function to convert multi-dimensional array to xml
+// create new instance of simplexml
+
+// $xml = new SimpleXMLElement('<root/>');
+
+// function callback
+// array2XML($xml, $my_array);
+
+// save as xml file
+// echo (($xml->asXML('data.xml')) ? 'Your XML file has been generated successfully!' : 'Error generating XML file!');
+
+function arrtoxml($root_elem,$arr) {
+ $xml = new SimpleXMLElement('<' . $root_elem . '/>');
+ array2XML($xml,$arr);
+ return $xml->asXML();
+}
+
+function array2XML($obj, $array)
+{
+ foreach ($array as $key => $value)
+ {
+ if(is_numeric($key))
+ $key = 'item' . $key;
+
+ if (is_array($value))
+ {
+ $node = $obj->addChild($key);
+ array2XML($node, $value);
+ }
+ else
+ {
+ $obj->addChild($key, htmlspecialchars($value));
+ }
+ }
+}