What is the best practice for passing PHP arrays to JavaScript in an Ajax call?

When passing PHP arrays to JavaScript in an Ajax call, the best practice is to encode the array into JSON format using the `json_encode()` function in PHP. This ensures that the array is properly formatted and can be easily parsed in JavaScript. Once encoded, the JSON string can be passed as a data parameter in the Ajax call and then decoded back into a JavaScript object using `JSON.parse()`.

<?php
// Sample PHP array
$myArray = array('apple', 'banana', 'orange');

// Encode the PHP array into JSON format
$myJson = json_encode($myArray);

// Output the JSON string
echo $myJson;
?>