我怎樣才能拼接如果ID(密鑰)的值是相同的其它ID(密鑰)的值的密鑰值多維陣列串連值
PHP
$locations = Array(
[0] => Array(
"id" => 1,
"latitude" => "51.541561",
"longitude", => "84.215",
"content", => "The quick brown"
)
[1] => Array(
"id" => 1,
"latitude" => "51.541561",
"longitude", => "84.215",
"content", => "fox jumps over the lazy dog"
)
[2] => Array(
"id" => 3,
"latitude" => "12.541561",
"longitude", => "32.215",
"content", => "Another content"
)
)
我想讓它像這樣:
$locations = Array(
[0] => Array(
"id" => 1,
"latitude" => "51.541561",
"longitude", => "84.215",
"content", => "The quick brown fox jumps over the lazy dog"
)
[2] => Array(
"id" => 3,
"latitude" => "12.541561",
"longitude", => "32.215",
"content", => "Another content"
)
)
基本上我想連接內容(鍵)的值,如果id(key)與其他id(key)值相同。
任何幫助將不勝感激。
編寫一個簡單的'爲/ foreach'循環 – 2014-11-24 08:04:41