There is an array, say $array1 , containing values:

 $array1 => ('дыня', 'дыня', 'банан', 'банан', 'банан') 

The result of the function should be an array containing something like:

 $array2['банан']['сколько_значений_банан_в_массиве1'] $array2['дыня']['сколько_значений_дыня_в_массиве1'] 

What function will sort $array1 into $array2 ?

Closed due to the fact that the question is too common for the participants Visman , Alexey Shimansky , user194374, Alex , fori1ton Jan 5 '17 at 13:46 .

Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See “How to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • four
    Is it difficult to use the built-in function array_count_values php.net/manual/ru/function.array-count-values.php ? - Alexey Shimansky
  • Yes, maybe it's not difficult, I just do not know how to do it, I'm just starting to learn php, and asked for an example of the working function - Daddyman
  • As it turned out, this is exactly what is needed array_count_values - Daddyman
  • it is necessary to learn a language from the very basics and at least from a small inspection and acquaintance with popular common functions for working with arrays / strings / files. And only after that write something - Alexey Shimansky
  • 2
    @Daddyman Yes, setting a task and solving it is a good way. But you set the task and ask others to solve it;) - Semushin Sergey

1 answer 1

 $array1 = array('дыня', 'дыня', 'банан', 'банан', 'банан'); print_r(array_count_values($array1));