How can I read data from a JSON file using PHP? Example code: - Biz Tech

How can I read data from a JSON file using PHP? Example code:

Listen
// Read JSON file
$json_data = file_get_contents("data.json");

// Decode JSON data
$data = json_decode($json_data, true);

// Loop through each item in data
foreach ($data as $item) {
    echo "Name: " . $item["name"] . " - Age: " . $item["age"] . "<br>";
}