2014-11-05 19 views
0

排序這是我的數組,我嘗試發送的用戶電子郵件的技巧,但電子郵件重複,如何將這個數組中的PHP

[email protected] | Angular JS 
[email protected] | JQuery 

[email protected] | Linux 
[email protected] | JQuery 
[email protected] | Angular JS 

[email protected] | JQuery 
[email protected] | Angular JS 

[email protected] | Linux 
[email protected] | Microsoft Dot Net 
[email protected] | Angular JS 

,但我希望通過電子郵件ID拆分陣列順序

[email protected] | {Angular JS, JQuery} 

[email protected] | {Linux, JQuery, Angular JS} 

[email protected] | {JQuery, Angular JS} 

[email protected] | {Linux, Microsoft Dot Net, Angular JS} 

請幫助,提前感謝...

+0

這裏提供你的php數組 – 2014-11-05 11:19:46

+0

第一個數組是我的mysql數組(這是我的...)在這行後 – 2014-11-05 11:24:28

+0

這個數組是無效的,因爲你總是超過同一個鍵。你的意思是,它是你查詢的結果集嗎? – vaso123 2014-11-05 11:24:51

回答

1

只是要精確:你想「團」,而不是「排序」 下面是一個例子:

$newArray = []; 
foreach($your_array as $row){ 
    // [0] gets email, [1] gets skill 
    $newArray[$row[0]][] = $row[1]; 
} 

ksort($newArray); 
+0

是的我想「羣」 – 2014-11-05 11:25:56

+0

謝謝@Etienne – 2014-11-05 11:43:12

相關問題