Page 1 of 1

array going backwards

Posted: Mon Mar 13, 2006 5:30 am
by shiznatix
ok I have a array like this

Code: Select all

[0] => username=bogus
[1] => channel => default
[2] =>
[3] => id=term_funk_soul
[4] => username=soul
[5] => number=soul
[6] => channel => outgoing_funk
and what I need to do is find the channel name thing and put it at the top of the section that it belongs to like this

Code: Select all

[0] => The channel is 'Default'
[1] => username=bogus
[2] => channel => default
[3] =>
[4] => The channel is 'outgoing_funk'
[5] => id=term_funk_soul
[6] => username=soul
[7] => number=soul
[8] => channel => outgoing_funk
I am having a rough time with this logic, any help?

Posted: Mon Mar 13, 2006 6:12 am
by onion2k
There's a couple of ways of doing that. First, and logically simplest, would be to break the array into a set of arrays, add the new elements, and then merge them back into being a big array..

Alternatively, you'll end up playing with array_splice() to add new elements. Tricky.

I'd break it up and then rebuild it personally .. unless it's massive.