How can JSON data be decoded and accessed in PHP?

To decode and access JSON data in PHP, you can use the `json_decode()` function which converts a JSON string into a PHP variable. You can then access the decoded data as an array or object depending on the second parameter you pass to `json_decode()`. Once decoded, you can access the data using array or object notation.

// JSON data to be decoded
$jsonData = '{"name": "John", "age": 30, "city": "New York"}';

// Decode the JSON data
$decodedData = json_decode($jsonData);

// Access the decoded data
echo $decodedData->name; // Output: John
echo $decodedData->age; // Output: 30
echo $decodedData->city; // Output: New York