json_encode
]Podporované v PHP 5 >= 5.2.0, PECL json >= 1.2.0
Syntax
string json_encode ( mixed $value [, int $options = 0 ] )
Popis
Príkaz jazyka PHP
Returns a string containing the JSON representation of value.
Parametre
value - The value being encoded. Can be any type except a resource. This function only works with UTF-8 encoded data.
options - Bitmask consisting of JSON_HEX_QUOT, JSON_HEX_TAG, JSON_HEX_AMP, JSON_HEX_APOS, JSON_NUMERIC_CHECK, JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES, JSON_FORCE_OBJECT, JSON_UNESCAPED_UNICODE.
Vrátené hodnoty
Returns a JSON encoded string on success or FALSE on failure.
Príklad
<?php
$arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);
echo json_encode($arr);
/*The above example will output:
{"a":1,"b":2,"c":3,"d":4,"e":5}
*/
?>
$arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);
echo json_encode($arr);
/*The above example will output:
{"a":1,"b":2,"c":3,"d":4,"e":5}
*/
?>
Pozri aj
json_decode, json_last_error
]