[UPHPU] Accessing object elements with punctuation marks
Alvaro Carrasco
alvaro at epliant.com
Thu Mar 29 11:36:05 MDT 2007
Richard K Miller wrote:
> This is probably a simple question but I'm not seeing it.
>
> I'm using simplexml_load_string() to convert an XML file into an object.
>
> $xml = simplexml_load_string($file);
>
> I can access the first node.
>
> print_r($xml->GetDomains);
>
> Output:
> SimpleXMLElement Object
> (
> [multirrp] => False
> [domain-list] => SimpleXMLElement Object
>
> But I can't access the next node down because it contains a hyphen:
>
> print_r($xml->GetDomains->domain-list); // produces error because
> of hyphen
>
> How do I get around this?
>
> Richard
>
>
>
Wrap it in curly braces:
$xml->GetDomains->{'domain-list'}
Alvaro
More information about the UPHPU
mailing list