How can JSON format be utilized for storing and retrieving data in PHP, and what are the advantages compared to text files?

JSON format can be utilized for storing and retrieving data in PHP by encoding data into JSON format using `json_encode()` and decoding JSON data using `json_decode()`. This allows for easy storage and retrieval of structured data in a human-readable format. Compared to text files, JSON format provides a more organized and standardized way of storing data, making it easier to work with and manipulate.

// Storing data in JSON format
$data = array(
    'name' => 'John Doe',
    'age' => 30,
    'email' => 'johndoe@example.com'
);

$jsonData = json_encode($data);
file_put_contents('data.json', $jsonData);

// Retrieving data from JSON format
$jsonData = file_get_contents('data.json');
$data = json_decode($jsonData, true);

echo $data['name']; // Output: John Doe