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
How is the comparison of objects done in php?
Why do we use inheritance in php?
How do I clear my browser session?
What is the use of header() function in PHP? What the Limitation of HEADER()?
What is the difference between md5(), crc32() and sha1() crypto on php?
How do you use an array in excel?
Explain the difference between isset() and empty()?
What the limitation of header() function in php?
What is the difference between single-quoted and double-quoted strings in php?
Is null function in php?
What does $_server means?
Explain what are the different errors in php?
Tell us what is the difference between session_unregister() and session_unset()?
What is helper function?
Explain me difference between mysql_connect and mysql_pconnect?