How can foreach be utilized in PHP to handle JSON data?

When working with JSON data in PHP, you can use the `json_decode` function to convert the JSON string into a PHP array. Once you have the data in an array, you can use a foreach loop to iterate over the elements and access the key-value pairs.

$jsonData = '{
    "name": "John",
    "age": 30,
    "city": "New York"
}';

$dataArray = json_decode($jsonData, true);

foreach ($dataArray as $key => $value) {
    echo $key . ': ' . $value . '<br>';
}