json_encode
json_encode — Returns the JSON representation of a value.Description
json_encode( mixed $value,Returns a string containing the JSON representation of the supplied value. The encoding is affected by the supplied flags and additionally the encoding of float values depends on the value of serialize_precision.
int $flags = 0,
int $depth = 512 ): string|false
Parameters
value
The value being encoded. Can be any type except a resource.
All string data must be UTF-8 encoded.
flags
Bitmask consisting of JSON_FORCE_OBJECT, JSON_HEX_QUOT, JSON_HEX_TAG, JSON_HEX_AMP, JSON_HEX_APOS, JSON_INVALID_UTF8_IGNORE, JSON_INVALID_UTF8_SUBSTITUTE, JSON_NUMERIC_CHECK, JSON_PARTIAL_OUTPUT_ON_ERROR, JSON_PRESERVE_ZERO_FRACTION, JSON_PRETTY_PRINT, JSON_UNESCAPED_LINE_TERMINATORS, JSON_UNESCAPED_SLASHES, JSON_UNESCAPED_UNICODE, JSON_THROW_ON_ERROR. The behaviour of these constants is described on the JSON constants page.
depth
Set the maximum depth. Must be greater than zero.
Return Values
Returns a JSON encoded string on success or false on failure.More information about json_encode on official PHP documentation site
json_encode - Popular snippets
- PHP 8.0 / MySQL 5.7 json_decode json_encode
last run:
2021-12-09 20:42:25
14
- PHP 8.1 / MySQL 5.7 json_encode
last run:
2022-09-27 15:11:53
9
- PHP 8.1 / MySQL 5.7 json_encode
last run:
2022-07-13 17:01:51
9
- PHP 8.1 / MySQL 5.7 json_encode
last run:
2022-07-13 15:35:09
8
- PHP 8.0 / MySQL 5.7 error_reporting var_dump json_decode json_encode
last run:
2022-02-09 14:08:16
8
- PHP 8.0 / MySQL 5.7 json_encode
last run:
2022-03-17 13:00:31
8
- PHP 8.1 / MySQL 5.7 header json_encode
last run:
2022-09-26 09:48:24
7
- PHP 8.1 / MySQL 5.7 count array_key_exists array_shift ksort json_encode
last run:
2022-07-31 17:03:37
7
- PHP 8.0 / MySQL 5.7 printf phpversion json_encode
last run:
2023-02-03 09:13:37
7
- PHP 8.1 / MySQL 8.0 printf phpversion json_encode
last run:
2022-05-07 05:47:22
6
json_encode - New snippets
-
PHP 7.4 / MySQL 5.7 json_encode array_reverse
added at:
2023-02-03 06:36:09
1
-
PHP 5.6 / MySQL 5.7 json_encode
added at:
2023-02-02 14:43:18
2
-
PHP 8.1 / MySQL 5.7 json_encode
added at:
2023-02-02 14:43:07
1
-
PHP 7.4 / MySQL 5.7 json_encode
added at:
2023-02-01 22:56:01
1
-
PHP 8.1 / MySQL 5.7 setlocale json_decode json_encode var_export
added at:
2023-01-27 08:24:12
1
-
PHP 8.1 / MySQL 5.7 setlocale json_decode json_encode var_export
added at:
2023-01-27 08:23:24
2
-
PHP 8.1 / MySQL 5.7 setlocale json_decode json_encode var_export
added at:
2023-01-27 08:23:03
1
-
PHP 8.1 / MySQL 5.7 setlocale json_decode json_encode var_export
added at:
2023-01-27 08:22:35
1
-
PHP 8.1 / MySQL 5.7 curl_init curl_setopt json_encode curl_exec curl_close
added at:
2023-01-22 23:16:52
1
-
PHP 8.1 / MySQL 8.0 count implode array_fill str_repeat json_encode
added at:
2023-01-22 14:09:41
2