I have an Array in a PHP variable called: $TillArray
I want to pass this value to a Javascript function and display an Alert for each item in the array.
Here is my code:
<script type="text/javascript">
ArrayFunction(<?= $TillArray ?>);
</script>
Here is the function code:
function ArrayFunction(MyArray)
{
for (var i = 0; i < MyArray.length; i++)
{
alert(MyArray[i]);
}
}
The function displays an "Undefined" message.
Can I please have some help to get this working?