sometimes I have in array list as 4,5,1,2 and sometimes 1,2,4,5. How could I reorder values in [list] ASC so I will have 1,2,4,5 and 1,2,3 etc in all [list] fields? Thank you.
Array
(
[0] => DibiRow Object
(
[storage:ArrayObject:private] => Array
(
[d] => 2012-04-03 08:30:00
[list] => 4,5,1,2
)
)
[1] => DibiRow Object
(
[storage:ArrayObject:private] => Array
(
[d] => 2012-04-03 09:00:00
[list] => 1,2,4,5
)
)
[2] => DibiRow Object
(
[storage:ArrayObject:private] => Array
(
[d] => 2012-04-03 09:00:00
[list] => 3,1,2 )
)
[3] => DibiRow Object
(
[storage:ArrayObject:private] => Array
(
[d] => 2012-04-03 09:00:00
[list] => 1,2,3 )
)
Try reading something about bubble sorting first. Then google it, find some examples and try to do it yourself. If you still have problems, come back and ask again, specifying what have you tried and what you think it's wrong with your method.
thank you. I found this solution (don't know if it is effective with large data):
for ($i = 0; $i < count($all) ; $i++) {
$num = $all[$i][list];
$resort = explode(",", $num);
sort($resort);
$resort = implode(",", $resort);
$all[$i][list] = $resort;
}
If this is based on the GROUP_CONCAT in results of previous query I wrote you can simply add ORDER BY to the GROUP_CONCAT() -
GROUP_CONCAT(DISTINCT user_bookings.user_id ORDER BY user_bookings.user_id)