I am trying to echo a multidimensional array from PHP to js, but it is giving me an error saying that “<” is an unexpected token.
js
var products = <?php echo json_encode( $products ) ?>;
Php
<?php
// PHP array
$products = array(
// product abbreviation, product name, unit price
array('choc_cake', 'Chocolate Cake', 15),
array('carrot_cake', 'Carrot Cake', 12),
array('cheese_cake', 'Cheese Cake', 20),
array('banana_bread', 'Banana Bread', 14)
);
?>