a::xml($array, $tag = 'root', $head = true, $charset = 'utf-8', $tab = ' ', $level = 0)

Converts an array to a XML string

  • $array (array)
    The source array
  • $tag (string)
    The name of the root element
  • $head (boolean)
    Include the xml declaration head or not
  • $charset (string)
    The charset, which should be used for the header
  • $level (int)
    The indendation level
  • return (string)
    The XML string

Example

<?php
$array = array(
 'cat'  => 'miao',
 'dog'  => 'wuff',
 'bird' => 'tweet'
);

echo a::xml($array, 'animals');

Result:

<animals>
  <cat>miao</cat>
  <dog>wuff</dog>
  <bird>tweet</bird>
</animals>