Alexander Foken: array_rand durch array_unique ergänzen?

Beitrag lesen

Moin Moin !

Hallo!

Was ist an http://www.php.net/manual/de/function.array-rand.php und den Kommentaren dort so schwer zu verstehen ?
Ich finde da auch keinen Kommentart zu diesem Thema.

Kommentar 1:

zak at php dot net
01-Sep-2000 06:55

If you have not yet been able to upgrade to PHP 4, then here is a function that duplicates

array_rand for PHP3.

[und eine Menge PHP-Code]

Kommentar 2:

ssmith at personalcarehmo dot com
14-Nov-2000 04:03

THE PROBLEM WITH fake_array_rand() IS THAT IT PRODUCES RESULTS THAT CONTAIN

DUPLICATES. WHAT IF YOU WANT TO RANDOMLY GO THRU EACH ELEMENT

OF THE ARRAY?

THEN THIS IS WHAT YOU'RE LOOKING FOR.

[und noch mehr PHP-Code]

Kommentar 1 liefert eine Funktion, die array_rand() für PHP3 nachbilden soll. Kommentar 2 sagt, daß diese Nachbildung problematisch ist, weil sie doppelte Einträge enthalten kann.

Daraus kann man mit etwas Nachdenken folgern, daß array_rand() eben keine doppelten Einträge liefert, denn sonst wäre die Nachbildung eben nicht problematisch.

Alexander

--
Nein, ich beantworte keine Fragen per eMail. Dafür ist das Forum da.
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so!"