Now Friends if your concept about array is cleared so now we can try to excute this 2D array in tabular form , that we clearly understand how data stores in an array
This is very easy concept I am sharing to understand how can we store the data in 2D array .
For example:
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>2D array</title>
</head>
<body>
<?php
error_reporting(0);
$x=array(
data_1=>array('name'=>'suraj kumar', 'dob'=> '20.10.1980', 'age'=> '30','salary'=>50000),
data_2=>array('name'=>'Amit kumar', 'dob'=> '22.1.1990', 'age'=> '30','salary'=>40000),
data_3=>array('name'=>'pankaj kumar', 'dob'=> '02.12.1990', 'age'=> '30','salary'=>20000),
data_4=>array('name'=>'Amit sharma', 'dob'=> '05.04.1960', 'age'=> '30','salary'=>10000),
data_5=>array('name'=>'suraj kumar', 'dob'=> '25.02.1964', 'age'=> '30','salary'=>70000),
);
echo"<table border=1>";
echo "<tr>";
foreach($x as $data)
{
foreach($data as $b)
{
echo "<td>". $b ."</td>";
}
echo "</tr>";
}
?>
</body>
</html>
This is very easy concept I am sharing to understand how can we store the data in 2D array .
For example:
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>2D array</title>
</head>
<body>
<?php
error_reporting(0);
$x=array(
data_1=>array('name'=>'suraj kumar', 'dob'=> '20.10.1980', 'age'=> '30','salary'=>50000),
data_2=>array('name'=>'Amit kumar', 'dob'=> '22.1.1990', 'age'=> '30','salary'=>40000),
data_3=>array('name'=>'pankaj kumar', 'dob'=> '02.12.1990', 'age'=> '30','salary'=>20000),
data_4=>array('name'=>'Amit sharma', 'dob'=> '05.04.1960', 'age'=> '30','salary'=>10000),
data_5=>array('name'=>'suraj kumar', 'dob'=> '25.02.1964', 'age'=> '30','salary'=>70000),
);
echo"<table border=1>";
echo "<tr>";
foreach($x as $data)
{
foreach($data as $b)
{
echo "<td>". $b ."</td>";
}
echo "</tr>";
}
?>
</body>
</html>
Comments