I have an array in my index.php which is created by a foreach:
foreach ($events as $eventkey =>$event)
{
echo "<li class='desktop-2 tablet-1 mobile-1'>".$event->title."<span class='eventLetter'>A</span><br/><span class='eventLocation'>".$event->city."</span></li>";
$LocationArray[]= $event->latlng;
}
json_encode($LocationArray);
Now I want to use this array, in my javascript ( which is written in a different file..). But CAN I do this? and if so, how? (I'm new to php, and I'm really bad at AJAX stuff etc.. I've been looking around here and other sites but I can't really find the solution.)
The plan is to be able to loop over the array in my javascript and place markers at a google map which I have on my site.
echo '<script...>var arr=array('; (here go php code to output values into JS array) );</script>';
.