SimpleXMLElement Minus / Hyphon in Element Name

Just came across a bit of a time-waster in the PHP SimpleXMLElement lib.  Usually if you’re accessing an element called, say ‘username’ you use the follwoing syntax:

[code]

$username = $element->username;

[/code]

However if the element has a minus sign in its name, like ‘user-name’ you have to use the following syntax instead:

[code]

$username = $element->{‘user-name’};

[/code]

If you use the original syntax no data will be returned, mad stuff, I would have wasted much more time on this if it wasn’t for this post – Thanks for the dig-out!