Convert Array to JSON String in PHP

<?php 

$product = array(
    'id' => 'p01',
    'name' => 'name 1',
    'price' => 4.5,
    'category' => array(
        'id' => 'c1',
        'name' => 'category 1'
    ),
    'colors' => array('red', 'green', 'blue', 'yellow')
);

header('Content-Type: application/json');
echo json_encode($product);

?>       
    
{"id":"p01","name":"name 1","price":4.5,"category":{"id":"c1","name":"category 1"},"colors":["red","green","blue","yellow"]}