|PHP Tutorial | PHP Resources | PHP Server||
What is an array? You have to understand what is it before start using it. An array is a variable which allows you to store multiple value within it! Here is an illustration. Have you ever saw a file cabinet usually found in offices, a cabinet where there's a lot of drawers to store important files for easy searching and organizing? That is what array similar to.
In PHP, it is possible to store an array within an array. PHP has the flexibility to array handling! If using the above example to illustrate it, then it would be storing a file cabinet within a file cabinet. How's that sound? Hmm ... Unfortunately, it is impossible :)
Well, to start using an array, the first step is to create an array variable.
<?phpWhen PHP read this code, it will assign this variable $color as an array. But it is empty. It still has no elements within it. Now we are going to place some highly confidential files into this cabinet.
<?phpTake a look at how those elements are stored within it. First, you have to use double quote for opening and closing of a string and then followed by a comma which tells PHP to seperate each element from the others.
How to identify those array?
Thus, when you want to access an element of an array, you have to enter the array variable $color followed by the key number. Let say you want to print out those values stored inside. It can be done like this:
And the result will be
Optimize Website - Webmasters optimize their site and gain higher search engine ranking
Free Photo Hosting - Free File Hosting, Free ZIP file Hosting, Free Image Hosting, Free MP3 Hosting.
Stupid Videos - Custom Pimped Motorcycle Pictures, Videos, and ArticlesSt Louis Computer Networking
Website Templates - 1000s of Templates $5 - Many Templates to help you build your site!
Each and every tutorial published in PHPhelps.com is originally written by PHPHELPS OWNERS. None of the content is allowed to be replicated without prior notice to writter.
Copyright © 2006 PHPhelps.com