|
One use is reading data from the database into its own array. The array keys would presumably match the column field names.
It is easier, and more readable, to use an array in this manner rather than individual $table_field variables set up for them. For instance, try iterating through a result set (which is probably returned in an array to begin with) with a foreach( $results as $ result ) loop.
At any rate, arrays are used to hold the data that is returned from the database query. Where else would you put the results?
Arrays are also good for setting up temporary datasets before implementing into an actual database, or even using them outright for such a purpose. Lets say you have a limited amount of locations that you want to concentrate on with city, county, zipcode keys and there are only twenty or so results for that array. It is simpler to create a static array than going through a database.
Last edited by RonnieTheDodger; 02-21-2011 at 03:27 PM..
|