@PunkPukeJan 20.2005 — #Array? Arrays run from Zero to Whatever. Just like a number system.
Usually the first element in an array is Zero. Here is an example with US military structure. Officers on top and enlisted after, not including Warrant Officers though.
[code=php] <?php $Rank_Array = array ("General Of The Army","General","Lieutenant General","Major General","Brigadier General","Colonel","Lieutenant Colonel","Major","Captain","First Lieutenant","Second Lieutenant","Sergeant Major Of The Army","Command Sergeant Major","Sergeant Major","First Sergeant","Master Sergeant","Sergeant First Class","Staff Sergeant","Sergeant","Corporal","Specialist","Private First Class","Private E-2","Private"); ?> [/code]
If you want to get the General Of The Army... You would call $Rank_Array[0].
If you want the worst rank of Unranked Private E-1... You would call $Rank_Array[23] (Which means 24 because of the Zero).
@NogDogJan 20.2005 — #Unless, of course, you do this... [code=php] $myArray = array(1=>"one", "two", "three"); printr($myArray); [/code] ...in which case your array would start indexing at 1 instead of 0. ?
@PunkPukeJan 20.2005 — #Yes, PHP has many MANY things for arrays/functions for arrays.
An example would be array_reverse($the_array). Which I believe that is the function to reverse an array so that you would get the last for $the_array[0] and first for the last number in the array.
Documentation is here: [URL]http://us2.php.net/array[/URL]
You can have arrays within arrays within arrays, it's called a Multidimensional Array. They aren't used often, but when I first started and I didn't yet have a SQL database, I used a main file with them to add and remove people (it was a closed website). Including preferences (Like a "Manual Database").
Like this for example (take away the carriage returns if you get confused)... [code=php] <?php //Because I'm hungry $Food = array( 'CheeseBurgers'=>array('Single Burger', 'Double Burger', 'Big Mac'), 'Fries'=>array('Small Fries', 'Large Fries'), 'Apple Pie', 'Drinks'=>array('Small Drink', 'Medium Drink', 'Large Drink', 'Super Size Drink') );
I'm a little rusty on the multidimensional and Labeling of arrays because I rarily do it. But, all of this should be legit. To automatically echo the contents of an array you would use a loop, If you want me to show you that also, I can. But, make sure you have this down first.
Actually another thing to note is that computers hardly ever go pass a few dimensions in arrays and that most humans just can't contemplate the Array Within the array within the array after 4 or more usually. This actually sucks up a lot of CPU usage. But, who cares. ?