PHP 8 · Strings and arrays
Encode and decode JSON
Convert to and from JSON, throwing exceptions on errors.
$json = json_encode($data, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT);
$data = json_decode($json, true, flags: JSON_THROW_ON_ERROR);
PHP 8 · Strings and arrays
Convert to and from JSON, throwing exceptions on errors.
$json = json_encode($data, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT);
$data = json_decode($json, true, flags: JSON_THROW_ON_ERROR);
Was this page helpful?