How to convert Multidimensional PHP array to JavaScript array?

JavascriptWeb DevelopmentFront End Technology

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', ''),
   array('Rahul, ''),

Converting PHP multidimensional array into JavaScript.

   var arr = <?php echo json_encode($myArr); ?>;

Now, let’s finally learn how to access it to output the email.

Published on 14-Feb-2018 12:50:54