J'ai la fonction ci-dessous. Je veux ajouter un support pour le format de temps iso8601 mais je n'arrive pas à le faire fonctionner. Depuis je ne peux pas faire php (string)$tag->iso8601.time
. Est-il possible d'obtenir l'élément iso8601.time? Le tag
est un SimpleXMLElement
.Obtenir la balise iso8601.time de SimpleXMLElement en PHP
private function _tagToPhpType($tag) {
/*
* <i4> or <int> four-byte signed integer -12
* <boolean> 0 (false) or 1 (true) 1
* <string> string hello world
* <double> double-precision signed floating point number -12.214
* <dateTime.iso8601> date/time 19980717T14:08:55
* <base64> base64-encoded binary eW91IGNhbid0IHJlYWQgdGhpcyE=
*
* Source: http://www.xmlrpc.com/spec
*/
if(!empty($tag->string)) {
return (string)$tag->string;
}
elseif(!empty($tag->int)) {
return (int)$tag->int;
}
elseif(!empty($tag->i4)) {
return (int)$tag->i4;
}
elseif(!empty($tag->boolean)) {
return (bool)$tag->boolean;
}
elseif(!empty($tag->double)) {
return (double)$tag->double;
}
elseif(!empty($tag->base64)) {
// @todo: Decode BASE64
return (int)$tag->base64;
} // @todo: Add iso8601 time type
else {
return (string)$tag;
}
}