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

Can you explain, when to use if-else if-else over switch statements?

539


How can we display information of a variable and readable by a human with php?

539


Explain the advantages of using PHP?

559


What is the meaning of symbol '$' in jquery?

538


What are sql functions?

540






How to call php function from javascript using ajax?

520


What is the difference between laravel and php?

506


Is php dead 2019?

541


What is php date function?

576


What is an anti csrf token?

506


Name some of the constants in php and their purpose.

537


Is php better than java?

547


What should be the length of variable for SHA256?

533


What changes I have to do in php.ini file for file uploading?

564


How could I install codeignitor ?

1744