json_encode

(FW >= 1.0)

json_encode- JSON-encode an array into a string

Description

int json_encode( mixed $arr, int method  )
Create a JSON-encoded representation of an array.  If the $method is 0, the resultant JSON code will represent an object, and if $method is 1, it will represent an array.

Parameters

$arr

array to parse

$method

If the $method is 0, the resultant JSON code will represent an object, and if $method is 1, it will represent an array.

Return Value

returns a string of the JSON-encoded array

Examples

<? 
$arr=array();
$arr['name']="John";
$arr['age']=33;
// encode as an object
$json=json_encode($arr,0);
print($json);
/* output will be:
{"name":"John","age":33}
*/
// encode as an array
$json=json_encode($arr,1);
print($json);
/* output will be:
["John",33]
*/

?>