I have a mutidimensional array:
Array
(
[0] => Array
(
[place_id] => 2225
[place_name] => NEW YORK
[alarm] => PING
[name_connection] => New-York-01
[name_connection_id] => 11175
[status] => 1
)
[1] => Array
(
[place_id] => 2225
[place_name] => NEW YORK
[alarm] => PING
[name_connection] => New-York-03
[name_connection_id] => 4324
[status] => 1
)
[2] => Array
(
[place_id] => 1345
[place_name] => DALLAS
[alarm] => PING
[name_connection] => Dallas-03
[name_connection_id] => 6666
[status] => 1
)
)
If i use foreach i get the output, but i would like to get the output grouped by the first key-Value or second (place_id or place_name) if they are the same. So basicly i woudl like to get the output like this:
NEW YORK
New-York-01 | 11175 | 1
New-York-03 | 4324 | 1
DALLAS
Dallas-03 | 6666 | 1
If i use standard foreach:
foreach($place as $rowplace){
$place_name3 = $rowplace['place_name'];
$name_connection3 = $rowplace['name_connection'] ;
echo'
<font color="green"> <b>'.$place_name3 .'</b><br>
'.$name_connection3.'</font> <br>';
}
I gout output like this:
NEW YORK
New-York-01 | 11175 | 1
NEW YORK
New-York-03 | 4324 | 1
DALLAS
Dallas-03 | 6666 | 1
So NEW YORK (place_name) is duplicated. How can i merge or group by results based on that key-value?
Thanks, Misko