I have the situation to swap array with condition.My array is plotted bellow.
- pid => like primary key in mysql so it may loose it order
- type=> type indicates, product type.array having 3 type of products.
- Name=> Simply indicates product name
First I tried solution in mysql, But I didn't got any good sign.Some of them suggest me array swapping is better one. But I don't know How to get this one.
My problem
I am having list of items.When i listing products, type 3(mater) should not come at 5,10,15 (i.e modules of 5 ) positions.If it does my design getting collapse.
Screen Shot explanation
So i want to make sure type 3(master) never comes at mod of 5 position.How can i do this Help me
My previous try in mysql here
Array
(
[0] => Array
(
[pid] => 1
[type] => 1
[name] => A
)
[1] => Array
(
[pid] => 2
[type] => 1
[name] => B
)
[2] => Array
(
[pid] => 3
[type] => 2
[name] => D
)
[3] => Array
(
[pid] => 4
[type] => 3
[name] => E(master)
)
[4] => Array
(
[pid] => 5
[type] => 3
[name] => f(sub)
)
[5] => Array
(
[pid] => 6
[type] => 1
[name] => A1
)
[6] => Array
(
[pid] => 7
[type] => 2
[name] => B1
)
[7] => Array
(
[pid] => 8
[type] => 1
[name] => C1
)
[8] => Array
(
[pid] => 9
[type] => 2
[name] => D1
)
[9] => Array
(
[pid] => 10
[type] => 3
[name] => E1(master)
)
[10] => Array
(
[pid] => 11
[type] => 3
[name] => A2(sub)
)
[11] => Array
(
[pid] => 12
[type] => 2
[name] => B2
)
[12] => Array
(
[pid] => 13
[type] => 1
[name] => C2
)
[13] => Array
(
[pid] => 14
[type] => 2
[name] => D2
)
[14] => Array
(
[pid] => 15
[type] => 1
[name] => E2
)
)
Thanks in advance