camelCaseToDelimiterArray() public static method

public static camelCaseToDelimiterArray ( $array, $delimiter = '-' )
Example #1
0
 /**
  * arrays passed to this method should have a single root element
  * with an array as its value
  * @param array $aData the array of data
  * @return string XML string
  */
 public static function arrayToXml($aData)
 {
     $aData = Util::camelCaseToDelimiterArray($aData, '-');
     // set up the XMLWriter
     $writer = new XMLWriter();
     $writer->openMemory();
     $writer->setIndent(true);
     $writer->setIndentString(' ');
     $writer->startDocument('1.0', 'UTF-8');
     // get the root element name
     $aKeys = array_keys($aData);
     $rootElementName = $aKeys[0];
     // open the root element
     $writer->startElement($rootElementName);
     // create the body
     self::_createElementsFromArray($writer, $aData[$rootElementName], $rootElementName);
     // close the root element and document
     $writer->endElement();
     $writer->endDocument();
     // send the output as string
     return $writer->outputMemory();
 }