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 are the method available in form submitting?

717


What does explode do in php?

738


How long does a session last in php?

688


What is difference between isset and empty in php?

733


Is age interval or ordinal?

699


How to remove blank spaces from the string?

716


How send email using php?

711


How could I install codeignitor ?

1948


What is the use of nl2br() in php?

772


What are the steps involved to run php?

788


What is asort php?

710


Differences between get, post and request methods ?

723


How does php server work?

739


How big is nvarchar max?

764


What is the difference between get and post method in php?

686