Is there any function to find repeated value in an array?
What is w2 standard



Is there any function to find repeated value in an array? What is w2 standard..

Answer / 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

More PHP Interview Questions

How to remove duplicate values from a PHP Array?

0 Answers  


What is the functionality of md5 function in php?

0 Answers  


What is implode() in php?

0 Answers  


what is code for email sending through localhost pc..?

2 Answers  


What are the different methods of passing data or information between two calls of a web page? What are the advantages/disadvantages of these methods?

4 Answers   Ardo, Patni,


What is a http session?

0 Answers  


Which cryptographic extension provide generation and verification of digital signatures?

0 Answers  


programm for factorial

1 Answers  


How to get length of an array in PHP?

0 Answers  


How to get the value of current session id?

0 Answers  


What is the function of mysql_real_escape_string in php?

0 Answers  


Do you know how can we check the value of a given variable is a number?

0 Answers  


Categories