Accessing multi-word properties

From: Date: Sun, 20 Feb 2011 10:32:36 +0000
Subject: Accessing multi-word properties
Groups: php.general 
Request: Send a blank email to php-general+get-311455@lists.php.net to get a copy of this message
Hi. I have a JSON, let's say "{\"a b\": 13}". json_decode() handles it properly. However, then resulting object has a property composed of two words. What I did to access this property was the following: $json = "{\"a b\": 13}"; $decoded = json_decode($json); $tag = "a b"; print($decoded->$tag); However, this seems clumsy. Is there another, nicer way to access multi-word props in PHP? I suppose there should be, due to the loosely typed nature of PHP, where everything is a map, but I couldn't find it. br, flj -- Fine counsel is confusing, but example is always clear. (Edgar A. Guest, The Light of Faith)

« previous php.general (#311455) next »