Zest.

PHP: JSON encode and decode

A short, tested PHP example for json encode and decode. Copy it and adjust the names and paths for your project.

PHP
$json = json_encode(["a" => 1, "b" => [1, 2]], JSON_PRETTY_PRINT);
$data = json_decode($json, true);   // true = associative arrays

Find it in Zest

Search for “php json encode and decode” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.

More PHP examples

All PHP examples