Is there any function to find repeated value in an array?
What is w2 standard
Answer Posted / amitverma
Yes, there's a function for everything in PHP :)
To see the repeated values in an array you may use function
array_count_values($array);
This function will return you an array, consisting each
vaule's frequency associated with it.
##
#Following Code -
$array = array(1, "hello", 1, "world", "hello");
print_r(array_count_values($array));
##
#Outputs -
Array
(
[1] => 2
[hello] => 2
[world] => 1
)
| Is This Answer Correct ? | 11 Yes | 3 No |
Post New Answer View All Answers
How can we determine whether a variable is set?
Tell me what is the meaning of a final class and a final method?
Explain mysql_error().
Why do we use polymorphism in php?
What is Gd PHP?
What are php variables?
How to increase the maximum execution time of a script in php?
What is a null coalescing operator in php7?
What is namespace and use in php?
What are the differences between php constants and variables?
Does php use html?
How to write php function in html onclick?
What is an object in php?
Is php still relevant 2019?
Does php pass arrays by reference?