![]() |
![]() |
-merrit- |
![]()
Post
#1
|
Goście ![]() |
Jak uzyskać tablicę bez powtarzających się wartości [link] w następującej tablicy?
Kod Array
( [0] => Array ( [title] => Some feed item [link] => http://www.example.com/article34 [description] => This article is really cool! [author] => Aart-Jan Boor [pubDate] => Sat, 08 Dec 2007 13:28:11 GMT ) [1] => Array ( [title] => Some feed item2 [link] => http://www.example.com/article34 [description] => This article is really cool too! [author] => Aart-Jan Boor [pubDate] => Sat, 08 Dec 2007 12:57:56 GMT ) [2] => Array ( [title] => Some feed item3 [link] => http://www.example.com/article4523 [description] => This article is the best! [author] => Aart-Jan Boor [pubDate] => Sat, 08 Dec 2007 12:39:42 GMT ) ) |
|
|
![]() |
![]()
Post
#2
|
|
Grupa: Moderatorzy Postów: 8 989 Pomógł: 1550 Dołączył: 8.08.2008 Skąd: Słupsk/Gdańsk ![]() |
Bawisz się z array_unique badz...
Kod function deleteDuplicate($tab) { $unique=array(); $ile=count($tab); // KONIECZNE! for($i=0; $i<$ile; $i++) { if(!in_array($tab[$i]['link'], $unique) $unique[]=$tab[$i]['link'] else unset($tab[$i]); } // jeżeli chcesz jeszce zresetować klucze na koniec to daj $tab=array_merge($tab); return $tab; } print_r(deleteDuplicate($tab)); Tablica wynikowa to: Kod Array
( [0] => Array ( [title] => Some feed item [link] => http://www.example.com/article34 [description] => This article is really cool! [author] => Aart-Jan Boor [pubDate] => Sat, 08 Dec 2007 13:28:11 GMT ) [2] => Array ( [title] => Some feed item3 [link] => http://www.example.com/article4523 [description] => This article is the best! [author] => Aart-Jan Boor [pubDate] => Sat, 08 Dec 2007 12:39:42 GMT ) ) |
|
|
![]() ![]() |
![]() |
Aktualny czas: 6.10.2025 - 03:59 |