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

Explain the syntax for ‘foreach’ loop with example.

495


What is the string concatenation operator in php?

516


Is key in array php?

585


How many open modes available when a file open in PHP?

647


What is session and why do we use it?

550






What is php built on?

499


What are php loops?

531


How do you find the length of a string in php?

512


What is php artisan serve?

517


Does strlen include null?

574


What is print_r?

508


How do I debug php?

518


What is $this in php?

535


Is nan in javascript?

518


Is age nominal or ordinal?

509