PHP function to transform associative array to XML