

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to convert Multidimensional PHP array to JavaScript array?
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', 'amit@example.com'), array('Rahul, 'rahul@example.com'), );
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]);
- Related Questions & Answers
- How to convert PHP array to JavaScript array?
- PHP Multidimensional Array.
- How to do multidimensional array intersection using JavaScript?
- How to convert array to string PHP?
- How to convert a JavaScript array to C# array?
- How to check for multidimensional nature of an array in PHP
- Single dimensional array vs multidimensional array in JavaScript.
- Sort php multidimensional array by sub-value in PHP
- How to convert an array to SimpleXML in PHP?
- Sort multidimensional array by multiple keys in PHP
- Convert object to an array in PHP.
- How to convert an array into a complex array JavaScript?
- Convert integer array to string array in JavaScript?
- How to convert Array to Set in JavaScript?
- How to convert array to object in JavaScript
Advertisements