I have this array:
Array
(
[0] => stdClass Object
(
[client_id] => 70
[client_name] => Berws
[account_identifier] => ACL70
[ticket_identifier] => B21
[ticket_id] => 21
[stage_name] => New
)
[1] => stdClass Object
(
[client_id] => 75
[client_name] => ASDF
[account_identifier] =>
[ticket_identifier] => BB17
[ticket_id] => 17
[stage_name] => New
)
[2] => stdClass Object
(
[client_id] => 71
[client_name] => QWERT
[account_identifier] => ACI71
[ticket_identifier] => B15
[ticket_id] => 15
[stage_name] => Won
)
[3] => stdClass Object
(
[client_id] => 70
[client_name] => Berws
[account_identifier] => ACL70
[ticket_identifier] => B14
[ticket_id] => 14
[stage_name] => In Progress
)
)
Here the 0 and the 3rd index are under the same account, but are different ticket - they are linked.
I want to manipulate this array so that all the linked ticket under a account are grouped together in an array, and the rest to show as it is.
foreach($data as $result) {
if(in_array($value->account_identifier, $result)) {
echo $value->account_identifier;
}
}
I am expecting something like this:
[0] => stdClass Object
(
[client_id] => 70
[client_name] => Berws
[account_identifier] => ACL70
[ACL70] => (
[0] => (
[ticket_identifier] => B21
[ticket_id] => 21
[stage_name] => New
)
[1] => (
[ticket_identifier] => B21
[ticket_id] => 21
[stage_name] => New
)
)
)
I tried using in_array, but it doesn't give me any result.
How should I approach this?