You can use PHP array in JavaScript. It works for a single as well as the multidimensional array. Use the json_encode() method to achieve this.
The following is the Multi-dimensional PHP array.
$myArr= array(
array('Amit', '[email protected]'),
array('Rahul, '[email protected]'),
);Converting PHP multidimensional array into JavaScript.
<script> var arr = <?php echo json_encode($myArr); ?>; </script>
Now, let’s finally learn how to access it to output the email.
document.write(arr[1][1]);