ArrayExample.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>use of array in php</title>
</head>
<body>
<h1>use of array in php example</h1>
<?php
/*
|-------------------------------------------------
| array() language-construct makes a variable
| as array type. which contains key => value pairs.
| key can be integer or string & value - any value
|-------------------------------------------------
*/
$myArray = array();
$myArray[0] = 'name ';
$myArray[1] = 'address';
echo $myArray[0];
echo $myArray[1];
echo "<br>";
$myArray['name'] = 'cfsuman ';
$myArray['address'] = 'mohakhali';
echo $myArray['name'];
echo $myArray['address'];
echo "<br>";
/*
|-------------------------------------------------
| here is the total array with structure
|-------------------------------------------------
*/
echo "<pre>";
print_r($myArray);
echo "</pre>";
/*
|-------------------------------------------------
| it is a huge adventage of array in php that
| it key can take both number and string
|-------------------------------------------------
*/
$modon = array("abc" => "i am learning abc", 123 => 555);
echo $modon['abc'];
echo "<br>";
echo $modon['123'];
echo "<br>";
/*
|-------------------------------------------------
| here is the total array with structure
|-------------------------------------------------
*/
echo "<pre>";
print_r($modon);
echo "</pre>";
?>
</body>
</html>
No comments:
Post a Comment
leave your comments here..