

- 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
Display a two-dimensional array with two different nested loops in matrix form PHP?
Use two loops, one for row and another for column. Fr matrix form, use the tab \t in the nested loop like his −
twoDimensionalArray[row][col],"\t";
Example
<!DOCTYPE html> <html> <body> <?php $twoDimensionalArray = []; $value=7; for ($row = 0; $row <=2; $row++) { for ($col = 0; $col <=2; $col++) { $twoDimensionalArray[row][col] = $value; } } for ($row = 0; $row <=2; $row++) { for ($col = 0; $col <=2; $col++) { echo $twoDimensionalArray[row][col],"\t"; } echo "<br>"; } ?> </body> </html>
Output
777 777 777
Above, you can see the output is in matrix form 3x3.
- Related Questions & Answers
- Display two different columns from two different tables with ORDER BY?
- Split one-dimensional array into two-dimensional array JavaScript
- How to form a two-dimensional array with given width (columns) and height (rows) in JavaScript ?
- Transpose of a two-dimensional array - JavaScript
- Create Two Columns with Two Nested Columns in Bootstrap
- Passing two dimensional array to a C++ function
- Working with two-dimensional array at runtime in C programming
- How to declare a two-dimensional array in C#
- How to create a two dimensional array in JavaScript?
- What is a two-dimensional array in C language?
- Creating a two-dimensional array with given width and height in JavaScript
- Difference Between One-Dimensional (1D) and Two-Dimensional (2D) Array
- C# program to Loop over a two dimensional array
- Create new instance of a Two-Dimensional array with Java Reflection Method
- Calculate Subtraction of diagonals-summations in a two-dimensional matrix using JavaScript
Advertisements