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 a php trait?
What is meant by urlencode and urldecode?
What is difference between rest api and restful api?
What are form input html tags?
How can you get the size of an image in PHP?
Explain mixed and callback functions?
What is php.ini & .htacess file?
What are the ways to include file in php?
How to run a php script?
Explain the difference between $var and $$var?
How to set a page as a home page in a php based site?
Which operator is used to combine string values in php?
What are the encryption functions available in PHP?
Which MySQL function would you use to select a database?
How many escape sequences are recognized in double-quoted strings in php?