>> how can you explain someone in a simplest and everyday use example of ARRAY.
> 
> The manual page explains it pretty succinctly. I don't think you'll get
> more simple than this, as there is obvious prerequisite knowledge
> assumed (i.e. that you know what a simple variable is, etc)

Hi saeed,

Ash means this:

http://www.php.net/manual/en/language.types.array.php

See the examples in grey-colored boxes.

Arrays are just a collection of things.  Similar to when you assign one 
variable one value.. well with an array you assign many variables one value 
each.  But the reason you use an "array" is that instead of a bunch of separate 
variables, you want those variables to be part of a collection..  i.e. all 
those variables have something in common.. like for example you might use one 
array to describe the parts of a car, and another array to describe all the 
fruits in your kitchen.

You could do this:  (all separate independent variables)

$part1 = 'spark plug';
$part2 = 'rear-view mirror';
$part3 = 'steering wheel';
etc.

$fruit1 = 'apple';
$fruit2 = 'banana';
$fruit3 = 'orange';
etc.

...but (depending on your application, and the logic you use), it might make 
more sense to do something like this instead: (make arrays!)

(these, below, are arrays where the key is just a number which is automatically 
assigned.  You can also use another syntax (see the manual) to make arrays 
where you generate your own custom keys, and those keys can be strings instead 
of numbers.)

$arrParts = array('spark plug', 'rear-view mirror', 'steering wheel');

$arrFruits = array('apple', 'banana', 'orange');


To use the arrays, there are tons of functions:

http://www.php.net/manual/en/ref.array.php

:-)

-Govinda
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to