![]() |
![]() |
-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 ![]() |
To widze, że ty się nie "zastanawiasz" tylko odrazu walisz takie głupoty.
Nawet nie umiesz poprawić kodu. Kod <?php 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]); } $tab=array_merge($tab); return $tab; } $tab=Array ( 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' ), 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' ), 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' ) ); print_r(deleteDuplicate($tab)); ?> I sprawdź sobie "wielki myślicielu" czy to nie działa poprawnie. -------------------- |
|
|
![]() ![]() |
![]() |
Wersja Lo-Fi | Aktualny czas: 14.08.2025 - 23:14 |