How can JSON be utilized to facilitate data transfer between PHP and JavaScript?

To facilitate data transfer between PHP and JavaScript, JSON can be utilized as a common data format that both languages can easily parse. PHP can encode data into JSON format using the `json_encode()` function, and JavaScript can decode JSON data using the `JSON.parse()` method. This allows for seamless communication between the two languages.

<?php
$data = array('name' => 'John', 'age' => 30, 'city' => 'New York');
$json_data = json_encode($data);
echo "<script> var jsonData = $json_data; </script>";
?>