| |
| * Link führt ins Internet |
|
| |
Befehl | Version | Beschreibung | Beispiel | Ausgabe |
Befehl
| array array_count_values ( array input ) |
Version
Beschreibung
Die Funktion array_count_values() zählt, wie oft jeder Wert innerhalb des Arrays
input vorkommt, und gibt das Ergebnis in Form eines neuen Arrays zurück. Jeder
Eintrag dieses Ergebnis-Arrays enthält als Wert eine Zahl, die angibt, wie oft
der Schlüssel in dem Array vorkommt. |
Beispiel
<?PHP
$array = array("PHP",4,"PHP",4,"PHP","SELFPHP");
$zaehle = array_count_values($array);
while(list($key, $val) = each($zaehle)) {
echo $key . " kommt " . $val . ' mal vor.<br>';
}
?>
|
Ausgabe
PHP kommt 3 mal vor.
4 kommt 2 mal vor.
SELFPHP kommt 1 mal vor.
|
|
|
|
|
|
|
|