Array

Learn Array in PHP

<!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>Untitled Document</title>
</head>

<body>
<h1>Array Demo</h1>

<?php

$cities = array(‘gujarat’=>array(0=>’ahemdabad’,1=>’Rajkot’,2=>’Vadodara’),
‘maharashtra’=>array(0=>’Mumbai’,1=>’Pune’),
‘madhya pradesh’=>array(0=>’Bhopal’));

$count = count($cities);
echo $count;
for($i=0;$i<$count;$i++)
{
echo “The State is “. key($cities). “<br>”;
next($cities);
}
foreach($cities as $st)
{
foreach($st as $st1)
{
echo ” The city is :” . $st1 . “<br>”;
}
}

?>
</body>
</html>

 

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.