Hello,
Here's the situation:
I have an array from a mySQL query. The array will have 9 keys and a number of values depending on the results of the search. However, I want to add 2 new keys to this array.
The 1st new key is a number, starting with 1 with the first value and auto-incrementing with each new row.
The 2nd new key is a function of another existing key.
To illustrate this, imagine the following array:
$array['NAME'] = John, Mark, Roger
$array['AGE'] = 25,28,31
$array['STATE'] = DC,NY,MA
new array:
$array['NAME'] = John, Mark, Roger
$array['AGE'] = 25,28,31
$array['STATE'] = DC,NY,MA
$array['ORDER'] = 1,2,3
$array['AGEPLUS5'] = 30,33,36
My first idea was to make a while() loop and simply add the keys like this:
$a = 0;
while ($array = mysql_fetch_array($mysqldata)) {
$a++;
$array['ORDER'] = $a;
$array['AGEPLUS'] = $array['AGE'] + 5;
}
Doesn't work though :queasy:
Suggestions?