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


Please Help Members By Posting Answers For Below Questions

What is a php trait?

699


What is meant by urlencode and urldecode?

846


What is difference between rest api and restful api?

741


What are form input html tags?

744


How can you get the size of an image in PHP?

750


Explain mixed and callback functions?

816


What is php.ini & .htacess file?

771


What are the ways to include file in php?

734


How to run a php script?

764


Explain the difference between $var and $$var?

710


How to set a page as a home page in a php based site?

720


Which operator is used to combine string values in php?

711


What are the encryption functions available in PHP?

833


Which MySQL function would you use to select a database?

834


How many escape sequences are recognized in double-quoted strings in php?

752