hi,
assume i got this array from a DB select statement
where i had an 'order by date desc'
Array
(
[CNT] => Array
(
[0] => 10
[1] => 9
[2] => 8
[3] => 7
[4] => 13
)
[OPI] => Array
(
[0] => 0
[1] => 7
[2] => 0
[3] => 1
[4] => 7
)
[DATE] => Array
(
[0] => 2205
[1] => 2105
[2] => 2005
[3] => 1905
[4] => 1805
)
)
those rows are ordered as expected by the field DATE (my format as example states only daysmonth).
What i'm tryng to accomplish is that:
i wanto to go trough all the rows of my array, look for the value of every [OPI] rows and do the following things.
If [OPI] value = 0 dont do anything
if [OPI] value = 1 then look at the corresponding [CNT] value, find all the rows where [OPI] = the [CNT] value and move those matched row below the row where i found the [OPI] value = 1
I don't know if i was enough clear due to my not so good english so i draw the initial state and the final state i would like to achieve.
my array from the select statement
|CNT|OPI|DATE //i go trough the rows
|10 | 0 |2205 // here nothing
| 9 | 7 |2105 //here nothing
| 8 | 0 |2005 //here nothing
| 7 | 1 |1905 // here i find opi = 1 so i look at his CNT value (7 in this case), i look for all the rows where OPI = 7 and i move all the matching rows below the one with OPI=1
|13 | 7 |1805 //here nothing
the final state after array manipulation
|10 | 0 |2205
| 8 | 0 |2005
| 7 | 1 |1905
| 9 | 7 |2105
|13 | 7 |1805
Hope to get some feedbach..because i 'm having hard time tryng to find the solution..
Thankyou in adwance for any hint.
best regards
dario colombo