PHP arrays are associative arrays with a little extra machinery thrown in.The associative part means that arrays store elementvalues in association with key values rather than in astrict linear index order. (If you have seen arrays in other programming languages, they are likely to have been vector arrays ratherthan associative arrays.) If you store an element in an array,in association with a key,all you need to retrieve it later fromthat array is the key value. For example, storage is assimple as this:

$state_location[‘San Mateo’] = ‘California’;

which stores the element ‘California’ in the array variable $state_location,in association with the lookup key ‘San Mateo’. After this has been stored,you can look up the stored value by using the key, like so:

$state = $state_location[‘San Mateo’]; // equals ‘California’

If all you want arrays for is to store key/value pairs, the precedinginformation is all you need to know. Similarly,if you want to associate a numerical ordering with a bunch of values,all you have to do is use integers as your key values, as in:

$my_array[1] = “The first thing”;$my_array[2] = “The second thing”;

If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in OneStopFAQs.com:-