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
What is full form of php? Who is the father or inventor of php?
Where to put php files in apache server?
Tell me how to find the position of the first occurrence of a substring in a string?
What is framework in php for beginners?
Write down the benefits of php7?
Can we override static method in php?
What is the difference between Split and Explode in PHP?
Explain difference between urlencode and urldecode?
What is the use session in php?
What is the difference between for and foreach?
how to track user logged out or not? when a user is idle?
Which function gives us the number of affected entries by a query?
How to remove duplicate values from array using php?
How to Retrieve a Cookie Value?
Do you know is it possible to extend the execution time of a php script?