Re: Accessing multi-word properties
| From: | bender | Date: | Sun, 20 Feb 2011 12:33:21 +0000 |
| Subject: | Re: Accessing multi-word properties | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-311458@lists.php.net to get a copy of this message | ||
Am 20.02.2011 11:32, schrieb Florin Jurcovici:
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, fljAhoi, print($decoded->{"a b"}); Gruß