| 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. <?php
When 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.
?> <?php
Take 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: <?php
?> Array looping <?php
?> And the result will be 0 red
1 blue 2 yellow |
Optimize Website - Webmasters optimize their site and gain higher search engine ranking Webmaster tools - Free online webmaster toolkits, website reporting and free PHP opensource scripts. Free Photo Hosting - Free File Hosting, Free ZIP file Hosting, Free Image Hosting, Free MP3 Hosting. Stupid Videos - Custom Pimped Motorcycle Pictures, Videos, and Articles Planet Diaz - Programming Community - Online programming resource for programmers all around the world Forectory - Webmaster Directory St Louis Computer NetworkingWebsite 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 |