Here is the php array i am using. I am trying to convert each entry into a string and pass it to the javascript variable, but when i use the following code I only get the first letter of each word in the php array.
<?php
$terms = array('cat', 'dog', 'bird');
$rand_keys = array_rand($terms);
?>
Javascript variable with php array data
var searchterms = <?php echo json_encode($terms[$rand_keys]); ?>;