PHP – Array

0 0
Read Time:49 Second

PHP – Array

An arrays is group of elements given one name. An array is a special variable, which can hold more than one value at a time.

  •  An array named Days could contain the days of the week
  •  Arrays start counting with element zero (not one)
PHP ARRAY CODEDIXA
  • An array is another data type–it is a collection of data that is given one name. An array is made up of a group of elements, which may either numbers or character strings. Each Element has a key and a value indicated by key=>value.
  • An array is arranged so that each item in the array can be located by using the key when needed.
  •  If you have a list of items (a list of car names, for example), storing the cars in single variables.

Example:

<?php
$cars = array("Volvo","BMW","Toyota");
echo "I like ".$cars[0].", ".$cars[1]." and ".$cars[2].".";
?>

Output:

I like Volvo, BMW and Toyota.
Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Comment

Verified by MonsterInsights