reformat existing array to group items together
I have the following array:
Array
(
[0] => Array
(
[name] => bss2
[label] => front
[text] => just a testing item
)
[1] => Array
(
[name] => bss3
[label] => front top
[text] => front top testing item
)
[2] => Array
(
[name] => J334
[label] => back top
[text] => masking test back top
)
[3] => Array
(
[name] => J3366
[label] => back
[text] => back non mask test
)
)
What i would like to accomplish is to check to see if label = front then
group the ones with front together and same with back all in one big array
to have it looks like so:
[approval] => Array
(
[0] => Array
(
[name] = front
[prev] = Array
(
[0]=>Array
(
[name] => bss2
)
[1]=>Array
(
[name] => bss2
)
)
)
[1] => Array
(
[name] = back
[prev] = Array
(
[0]=>Array
(
[name] => J334
)
[1]=>Array
(
[name] => J3366
)
)
)
)
so far I dont have much and am stuck but this is my code
foreach($info as $data) {
if(strtolower(strpos($data['label'], "front") !==false)) {
} else {
}
}
Any help is greatly appreciated thank you.
No comments:
Post a Comment