$json_string = json_encode($data, JSON_PRETTY_PRINT);
header('Content-Type: application/json');
JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES
composer require majorgrey/pretty_json
<?php
use MajorGreyPrettyJson;
$array = array(
"name" => "majorgrey",
'email' => "chuksjimg@gmail.com",
'metadata' => array (
'color' => 'blue',
'food' => 'chicken'
)
);
$json = json_encode($array);
$pretty_json = PrettyJson::print($json);
echo $pretty_json;
composer require majorgrey/pretty_json