+ 1
what is an array ? describe with example.
6 Answers
+ 1
An array is just a single variable that stores different information that is neat and organised. This PHP array is much similar to Java, as well as most other arrays in other languages:
$food = array("Orange", "Carrot", "Pizza");
// This defines the array "$food" and adds the foods
echo $food [1];
// This will echo "Carrot"
$food[] = "Apples";
// This will append "Apples" to the array "$food"
You can also go:
$foods_colors = array("Orange" => "Orange", "Carrot" => "Orange", "Apple" => "Red")
This is in PHP though, this is Java:
string food = {"Apples", "Carrots", "Pizza"}
System.out.println(food[1]);
// This will print "Carrots"
0
an array collection all variable in the same time
0
Hi Sadab,
Array is a collection of same type variables referred by the same name. Each element of array can be accessed via index. In Java, array index always integer starting from 0. Example and more detail of array available in http://javabasictoadvanced.blogspot.co.id/2016/05/array.html
0
An array is like having a basket which contains all the different kinds of fruits. You get to add what you want.
0
array is container which contain similar data type variables.
ex. int array[5]
array contain 5 integer value.. i.e. 5,6,7,8,1
0
The simplest form of example without any programming knowledge goes like this...
if your surname is bill and your parents have 5 kids. Without mentioning your first name and last name together, I can aswell call you by your surnames with an assigned number.
bill0 , bill1, bill2, bill3, bill4.