Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Unikalne wartości, z tablicy dwuwymiarowej
-merrit-
post
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
        )

)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
-merrit-
post
Post #2





Goście







array_unique próbowałem zanim jeszcze zapytałem na forum, nie działa tak jak należy, zwraca z tablicy tylko jedną wartość

co do tej funkcji

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'] // --------wywala błąd w tej linii
    else unset($tab[$i]);
}

// jeżeli chcesz jeszce zresetować klucze na koniec to daj $tab=array_merge($tab);
return $tab;
}


Parse error: syntax error, unexpected T_VARIABLE in /home/xxx/domains/xxx/public_html/test/xx.php on line xxx
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 3.10.2025 - 20:51