Support Forums

Full Version: What is array and the the use of it?can someone explain to me?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have read some php tutorials i have stucked in arrays.

so would someone teach me about arrays?what is it and where is usefull?
Arrays are a very usefull feature in PHP and you'll find yourself using then more than you think. An array is just a fancy term for storing multiple data in a single variable. Take the $_POST variable, it's an array and contains the data that was sent in a form, you access that data by using its unique id. Eg, $_POST["username"] contains the data sent that has the unique identifier of "username".

Do you seem to understand now?
Google probably has a much better explanation than me though, haha.
An array is used as an alternative to using multiple variables to hold values.

PHP Code:
<?PHP

$array 
= ("One""Two""Three"); //Define the array
Echo $array[0]; //Will echo "One"
Echo $array[2]; //Will echo "Three"

foreach ($array as $value){
Echo 
"$value, "//Will echo "One, Two, Three, "
}
?>