I would like to split an array of objects into multiple arrays by key=>value, but I couldn't figure it out how.
I have an array like this:
Array => (
[0]=>stdClass Object(
[id]=>1
[title]=> Title1
[content]=>Content1
[cat]=>Cat1
[date]=>20140910
)
[1]=>stdClass Object(
[id]=>2
[title]=> Title2
[content]=>Content2
[cat]=>Cat2
[date]=>20140910
)
[2]=>stdClass Object(
[id]=>3
[title]=> Title3
[content]=>Content3
[cat]=>Cat1
[date]=>20140910
)
)
and I would like to split this by "cat"=>"value" and create an array like this
Array => (
[Cat1] => Array(
[0] => Array(
[id]=>1
[title]=> Title1
[content]=>Content1
[cat]=>Cat1
[date]=>20140910
)
[1] => Array(
[id]=>3
[title]=> Title3
[content]=>Content3
[cat]=>Cat3
[date]=>20140910
)
)
[Cat2] => Array(
[0] => Array(
[id]=>2
[title]=> Title2
[content]=>Content2
[cat]=>Cat2
[date]=>20140910
)
)
)
So this is what I'm trying to do but I couldn't.