← All built-ins / json_encode_pretty()

json_encode_pretty()

json_encode_pretty(string $s): string

Parameters

NameTypeDescription
$vmixedvalue to encode

Return value

json_encode() with JSON_PRETTY_PRINT pre-applied.

Example

echo json_encode_pretty(["x" => 1]), "
";
{
    "x": 1
}

See also

json_encode()