I have an array full of dynamic <select> field options, that I would like to be split into separate arrays based on a certain value within each “loop”.
Basically, I’d like two arrays: one with the data associated with [subfirmdetailtype_id] = 14, and one with [subfirmdetailtype] = 25.
Any help would be appreciated!
Array
(
[0] => Array
(
[Subfirmdetailoption] => Array
(
[option] => Open
[subfirmdetailtype_id] => 14
)
)
[1] => Array
(
[Subfirmdetailoption] => Array
(
[option] => Closed
[subfirmdetailtype_id] => 14
)
)
[2] => Array
(
[Subfirmdetailoption] => Array
(
[option] => Large Growth
[subfirmdetailtype_id] => 25
)
)
[3] => Array
(
[Subfirmdetailoption] => Array
(
[option] => Large Blend
[subfirmdetailtype_id] => 25
)
)
[4] => Array
(
[Subfirmdetailoption] => Array
(
[option] => Large Value
[subfirmdetailtype_id] => 25
)
)
[5] => Array
(
[Subfirmdetailoption] => Array
(
[option] => Mid Growth
[subfirmdetailtype_id] => 25
)
)
[6] => Array
(
[Subfirmdetailoption] => Array
(
[option] => Mid Blend
[subfirmdetailtype_id] => 25
)
)
[7] => Array
(
[Subfirmdetailoption] => Array
(
[option] => Small Growth
[subfirmdetailtype_id] => 25
)
)
[8] => Array
(
[Subfirmdetailoption] => Array
(
[option] => Small Blend
[subfirmdetailtype_id] => 25
)
)
[9] => Array
(
[Subfirmdetailoption] => Array
(
[option] => Small Value
[subfirmdetailtype_id] => 25
)
)
[10] => Array
(
[Subfirmdetailoption] => Array
(
[option] => World Bond
[subfirmdetailtype_id] => 25
)
)
[11] => Array
(
[Subfirmdetailoption] => Array
(
[option] => Multisector Bond
[subfirmdetailtype_id] => 25
)
)
[12] => Array
(
[Subfirmdetailoption] => Array
(
[option] => Municipal Debt
[subfirmdetailtype_id] => 25
)
)
[13] => Array
(
[Subfirmdetailoption] => Array
(
[option] => Heigh Yield Muni
[subfirmdetailtype_id] => 25
)
)
[14] => Array
(
[Subfirmdetailoption] => Array
(
[option] => Heigh Yield
[subfirmdetailtype_id] => 25
)
)
)
This will group arrays the way you want:
Later you can access groups like this:
Or loop through these grouped arrays.