Monday, January 26, 2009

How to declare arrays in Php?

Example 1:

$names = array("Johnr","Mario","Merbert");

Example 2:
$names[0] = "John";
$names[1] = "Mario";
$names[2] = "Merbert";
echo $names[1] . " and " . $names[2] . " are ". $names[0] . "'s neighbors";

?>

You can the element or the value of the array using there indeces or index.

Example:
echo $name[2];

Output:

Mario

Download File

No comments:

Post a Comment

 

blogger templates | Make Money Online