Forum und email
json_encode

json_encode

(no version information, might be only in CVS)

json_encode -- Returns the JSON representation of a value

Popis

string json_encode ( mixed value )

Returns a string containing the JSON representation of value.

Seznam parametrů

value

The value being encoded. Can be any type except a resource.

This function only works with UTF-8 encoded data.

Návratové hodnoty

Returns a JSON encoded string on success.

Příklady

Příklad 1. A json_encode() example

<?php
$arr
= array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5);

echo
json_encode($arr);
?>

Výše uvedený příklad vypíše:

{"a":1,"b":2,"c":3,"d":4,"e":5}

Viz také

json_decode()