This is a good news. php 5.2 support JSON. It's very easy to use. I like it, because I can transfer data between JavaScript and PHP freely accroading to this functions.
Json_encode
(PHP 5> = 5.2.0, pecl json: 1.2.0-1.2.1)
Json_encode-returns the JSON representation of a value
Description
StringJson_encode(Mixed $ value)
Returns a string containing the JSON representationValue.
Parameters
-
Value
-
TheValueBeing encoded. can be any type before t a resource.
This function only works with UTF-8 encoded data.
Return values
Returns a JSON encoded string on success.
Json_decode
(PHP 5> = 5.2.0, pecl json: 1.2.0-1.2.1)
Json_decode-decodes a JSON string
Description
MixedJson_decode(String $ JSON [, bool $ assoc])
Takes a JSON encoded string and converts it into a PHP variable.
Parameters
-
JSON
-
TheJSONString being decoded.
-
Assoc
-
WhenTrue, Returned objects will be converted into associative arrays.
Return values
Returns an object or if the optionalAssocParameter isTrue, An associative array is instead returned.
Please link to www.php.net for more information.