How to Create Multi Dimensional Array in PHP

PHP

Multi Dimensional Array contain n numbers of sub  array . One Array Contain multiple arrays in there each index is called as Multi Dimensional Array. While using Print function we can check that how multi dimensional array looks like and how index are set.We will show you a simple example which will show you how you can create single array and add those single dimensional array to Multi Dimensional Array.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Example for Using Multidimensional Array in PHP</title>
</head>
<body>
<?php
//We Define a Blank Array
$my_array = array();

//My group of&nbsp; Array
$my_array_1 = array('a','b','c');
$my_array_2 = array('d','e','f');
$my_array_3 = array('g','h','i');

$my_array = array($my_array_1,$my_array_2,$my_array_3);

echo '<pre>';
print_r($my_array);

/*
Output
Array
(
[0] => Array
(
[0] => a
[1] => b
[2] => c
)

[1] => Array
(
[0] => d
[1] => e
[2] => f
)

[2] => Array
(
[0] => g
[1] => h
[2] => i
)

)
*/

?>
</body>
</html>
-->