Posted by: Sourav | February 9, 2011

Arrays in PHP


<html>
<head>
<title>
Arrays
</title>
</head>
<body>

<?php $array1=array(4,8,9,6,589,6,8,3,5,0);?>
<?php echo $array1[0];?><br />
<?php echo $array1[1];?><br />

<?php echo $array1[9];?><br />
<?php $array2=array(4,8,9,6,”sourav”,6,8,3,5,0);?>
<?php $array3=array(4,8,9,6,sourav,6,8,3,5,0);?>
<?php $array4=array(4,8,9,6,’sourav’,6,8,3,5,0);?>

<?php echo $array2[4];?><br />
<?php echo $array3[4];?><br />
<?php echo $array4[4];?><br />
<?php $array5=array(4,8,9,6,’sourav’,array(“a”,”b”,”c”),8,3,5,0,1,589);?>
<?php echo $array5[5];?><br />
<pre><?php print_r ($array5);?></pre><br />
<?php echo $array5[5][2];?><br />
<?php $array5[5]=”sourav23456789″;?>
<?php echo $array5[5];?><br />
<?php $array5[5][2]=”sourav”;?>
<?php echo $array5[5][2];?><br />
<?php $array6=array(“firstname”=>”Sourav”, “lastname”=>”Bhattacharya”)?>
<?php echo $array6[“firstname”];?><br />
<?php echo $array6[“firstname”].” “.$array6[“lastname”];?><br />
<?php  $array6[“firstname”]=”Sourav2″;?>
<?php echo $array6[“firstname”].” “.$array6[“lastname”];?><br />
</body>
</html>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: