Arrays
1. The Array object is used to store multiple values or more than one value in a similar data type variable.
2. Accessing a particular element in an array by referring to the name of the array and the index number.
3. The index number of array starts from 0.
4. If you specify numbers or true/false values inside the array then the variable type will be Number or Boolean, instead of String.
5. Note: Array is a key word.
2. Accessing a particular element in an array by referring to the name of the array and the index number.
3. The index number of array starts from 0.
4. If you specify numbers or true/false values inside the array then the variable type will be Number or Boolean, instead of String.
5. Note: Array is a key word.
An array can be defined in three ways:
Numeric array - An array with a numeric ID key
Associative array - An array where each ID key is associated with a value
Multidimensional array - An array containing one or more arrays
Numeric array - An array with a numeric ID key
Associative array - An array where each ID key is associated with a value
Multidimensional array - An array containing one or more arrays
Example: 1
<?php
$people[0] = "Oliva";
$people[1] = "Nicole";
$people[2] = "Natasha";
echo $people[1];
?>
$people[0] = "Oliva";
$people[1] = "Nicole";
$people[2] = "Natasha";
echo $people[1];
?>
Output
Nicole Another way
Example: 2
<?php
$people = array('Oliva', 'Nicole', 'Natasha');
echo $people[1];
?>
$people = array('Oliva', 'Nicole', 'Natasha');
echo $people[1];
?>
Output
Nicole
No comments:
Post a Comment