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.1 / PostgreSQL 12 json_encode
last run:
2024-04-19 10:37:42
34
- PHP 8.1 / MySQL 5.7 json_encode
last run:
2024-07-09 07:11:33
14
- 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 file_get_contents simplexml_load_string json_encode json_decode is_array in_array end
last run:
2023-11-12 20:48:05
13
- PHP 8.1 / MySQL 5.7 file_get_contents simplexml_load_string json_encode json_decode print_r
last run:
2024-02-28 17:46:26
12
- PHP 8.1 / MySQL 5.7 file_get_contents simplexml_load_string json_encode json_decode print_r array_unique
last run:
2023-11-01 17:43:41
12
- PHP 8.1 / MySQL 5.7 json_encode
last run:
2023-07-06 12:37:55
10
- PHP 8.1 / MySQL 5.7 file_get_contents simplexml_load_string json_encode json_decode print_r array_count_values is_array in_array end
last run:
2023-11-01 18:08:32
9
- PHP 8.0 / MySQL 5.7 json_encode
last run:
2023-07-06 12:38:42
9
- PHP 8.1 / MySQL 5.7 file_get_contents simplexml_load_string json_encode json_decode
last run:
2024-02-28 18:23:24
8
json_encode - New snippets
-
PHP 8.1 / MS SQL Server 2022 AdventureWorks (ReadOnly) json_encode
added at:
2024-09-08 08:47:09
1
-
PHP 8.1 / Firebird 4.0 (Employee) json_encode
added at:
2024-09-02 14:48:49
1
-
PHP 8.1 / MySQL 5.7 array_sum array_column json_encode array_values array_sum array_column json_encode array_values
added at:
2024-08-30 19:01:32
1
-
PHP 8.1 / MySQL 5.7 array_push json_encode
added at:
2024-08-16 23:14:58
1
-
PHP 8.1 / Firebird 4.0 (Employee) json_encode json_encode
added at:
2024-08-15 13:29:38
2
-
PHP 8.1 / Firebird 4.0 (Employee) json_encode
added at:
2024-08-15 11:37:34
1
-
PHP 8.1 / Firebird 4.0 (Employee) json_encode
added at:
2024-08-15 10:04:57
1
-
PHP 8.1 / Firebird 4.0 (Employee) json_encode
added at:
2024-08-15 09:19:46
1