Archive for November, 2009

Using PHP variables that contain hyphens

Posted in php on November 25th, 2009 by David – Be the first to comment

This took me a little while to work out. I’m using PHP5’s SimpleXML to parse XML into a PHP object. The XML has entries like <HELLO-THERE>.

But you can’t use $xml->HELLO-THERE because it reads the hyphen as a minus.

Instead, use $xml->{”HELLO-THERE”}

Easy!