I’m looping through a xml file, but I want to use an attribute name which has the “-” in it.
foreach( $xml as $person)
{
echo 'Name: '.$person->Name.'<br />';
echo 'Home address: '.$person->home-address.'<br />';
echo 'Away address: '.$person->away-address.'<br />';
}
The “-” symbol breaks the script, how do I make this work? I don’t want to rename the attribute.
Use curly brackets around the variable name: