I have an array in this format
Array
(
[0] => stdClass Object
(
[page_id] => 132
[link] => Savings
[count] => 5
)
[1] => stdClass Object
(
[page_id] => 172
[link] => Coverage
[count] => 5
)
)
I wish to convert this into the following format
Array
(
[Savings] => Array
(
[132] => 3
[172] => 5
)
[Coverage] => Array
(
[132] => 9
[172] => 9
)
)
I have tried the following code and getting result in the below format.
foreach($result_link as $data) {
$page_array[$data->link][] = array( $data->page_id => $data->count );
}
print_r($page_array);
Please help me to solve this.