I dynamically pull the following array from mysql table and need to assign index to each of the element.
Array
(
[yma] => 65.0000
[mhip] => 65.0000
[tzp] => 40.0000
[mzp] => 45.0000
[su] => 40.0000
[tkp] => 74.0000
)
here is my expected output.
Array
(
[0][yma] => 65.0000
[1][mhip] => 65.0000
[2][tzp] => 40.0000
[3][mzp] => 45.0000
[4][su] => 40.0000
[5][tkp] => 74.0000
)
Or
Array
(
[0] => 65.0000
[1] => 65.0000
[2] => 40.0000
[3] => 45.0000
[4] => 40.0000
[5] => 74.0000
)
There can be issue with the answer below if my desired output is like below:
Array
(
[0] => 'yma'
[1] => 'mhip'
[2] => 'tzp'
[3] => 'mzp'
[4] => 'su'
[5] => 'tkp'
)
I am using this code for pulling the data:
$myarray = array();
while($row = mysql_fetch_array($sql)){
$myarray[$row['pawl']] = $row['contribution'];
}
How can I take the array I am fetching/building from MySQL and generate the desired output?