NOVINKA: Najžiadanejšie rekvalifikačné kurzy teraz s 50% zľavou + kurz AI ZADARMO. Nečakaj, táto ponuka dlho nevydrží! Zisti viac:

PHP - array_count_values

Trieda

Koreň \ Bez triedy

Metóda - array_count_values

(PHP 4, PHP 5, PHP 7)

Returns an associative array containing counts of individual items in a given array.

Procedurálne

Parametre

Žiadne

Mávratovej hodnoty

Vracia: array

Returns an associative array, in which the keys are the counted items and the values are the item counts.

Príklady

This example outputs: Array (
[1] => 1,
[hello] => 2,
[world] => 1 )

<?php
$array = array("hello", "world", "hello", 1);
var_dump(array_count_values($array));

Súvisiace manuály

      • function array_unique (array $array, int $sort_flags = SORT_STRING) : array
      • function array_values (array $array) : array
      • function count (mixed $array_or_countable, int $mode = COUNT_NORMAL) : int
      Aktivity