Home
Credits
Affliates
Link Exchange

HTMLshaman
PHPshaman
LINUXshaman

Helpful Links
Web Design Images
Backgrounds
Icon Sets
GIF Images


Language Intro : Arrays

An Array is like a shelf with columns that stoes things in a specific order from 1 to the number you want it to end. PHP will automatically place an array number or index number everytime you place something into the array.

Lets start working with hardcoded variables.
Example :
$mashmellow[] = "Sweet";
$mashmellow[] = "Over Cooked";
$mashmellow[] = "Deep Fried";
$mashmellow[500] = "RAW";

Those that are without an index number will be placed in sequence, 1 for "Sweet", 2 for "Over Cooked" and so on. however if you place a number in the [] you will manually assign it to a specific location. In the above example, its 500.

Now what happens if we issue a print or an echo command? Example :
print $mashmellow[3];
The above gaves us "Deep Fried".

There are however many ways you can define an array and a good method would be as follows :
Example :
$mashcontainer = "mash1, mash2, mash3, mash4";
$mashmellow = array ( $mashcontainer );

This will produce that $mashmellow is the Array and $mashcontainer will become the stored values, allowing us to place values into the Array.

And if you call to print or echo the array $mashmellow[3], you will get the response "mash3".

We can also get the above to print all values in the Array with a foreach command.
Example with the recent example :
$mashcontainer = "mash1, mash2, mash3, mash4";
$mashmellow = array ( $mashcontainer );

foreach ( $mashmellow as $masharray )
{
print "$masharray is actually just another mashmellow.<br>"
}

What happens here is that it takes each and every value in the Array and then outputs it and added the "is actually just another mashmellow.<br>" line to it.
Tt will display as follows :
mash1 is actually just another mashmellow.
mash2 is actually just another mashmellow.
mash3 is actually just another mashmellow.
mash4 is actually just another mashmellow.

There are many other ways in which you can work with arrays like merging ( array_merge() ), removing ( array_shift() ) and so on, we will leave you to explore the possibilities as you progress in your own coding experience.






Basics
Introduction
Compilation for Apache

Language Intro
The Basics
Structuring
Script Flow
Functions
Arrays
Objects

Extras
Global values

Simple Scripts
MySQL Query
File Upload
List Contents






Disclaimer:
Contents on this site is provided for educational purposes and will not be distributing source codes from any major commercial reference.
Partial code may be used to provide better understanding of how the program works or functions to illustrate to the reader more clearly.
Other programs that are provided freely on the internet may be placed as a quick solution to the user's needs taking in consideration that it is not altered in any way.

Our Recommended Links
prepaid phone card
Online Casino
Smiley Central
Ventrilo Servers
Counter-Strike Servers
Advertise Here
Advertise Here
Advertise Here
Advertise Here
Advertise Here
phone card

Advertise Here
Advertise Here
Advertise Here
Advertise Here
Advertise Here
Advertise Here
Advertise Here
Hollywood Lyrics
Resident Evil
Contact us at webmaster@galacnet.com for advertising opportunities on GalacNet.