public
static
function
xmlToEncode(
$data
) {
$xml
=
""
;
foreach
(
$data
as
$key
=>
$value
) {
$attr
=
""
;
if
(
is_numeric
(
$key
)) {
$attr
=
" id='{$key}'"
;
$key
=
"item"
;
}
$xml
.=
"<{$key}{$attr}>"
;
$xml
.=
is_array
(
$value
) ? self::xmlToEncode(
$value
) :
$value
;
$xml
.=
"</{$key}>\n"
;
}
return
$xml
;
}