Skip to content

Instantly share code, notes, and snippets.

@Rudis1261
Created October 28, 2013 09:51
Show Gist options
  • Save Rudis1261/7194109 to your computer and use it in GitHub Desktop.
Save Rudis1261/7194109 to your computer and use it in GitHub Desktop.
Checking whether an array contains duplicate values or not
<?php
# Let's define a simple array to display the function
$array = array("How", "Now", "Brown", "Cow", "With", "The", "Brown", "Fox");
# Check if it contains a duplicate value?
if ( count($array) !== count(array_unique($array)) )
{
echo "Contains Duplicate";
}
# What if it doesn't contain a duplicate value, what then?
else
{
echo "Does not contain a duplicate";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment