How to check the duplicate values from array using php

Sponsors

Many times we need to array has duplicate values or not. Using php language this is very easy.

For checking the duplicate array value array_unique function is very useful.

Here I am giving you very simple php example:


<?php
 $array1 = array("banana","apple","pear","banana");

 if (count(array_unique($array1)) < count($array1))
 echo 'Duplicate entry found in array';
 else
 echo 'No Duplicate values found in array';
 ?>

Output:  Duplicate entry found in array

Incoming search terms:

You may like following Articles!

This entry was posted in PHP, tutorials and tagged , by Wordpress API. Bookmark the permalink.

About Wordpress API

API means Application Program interface. In Wordpress API we are giving all the information about wordpress API. We worked for many wordpress plugins and themes. We have expertise in PHP, Databases, Graphic Design, Ruby on Rails, Java, Wordpress, Drupal and many CMS. We always give you the best solutions about wordpress and other related topics in This Blog. We will give you always fresh tips and tricks and techniques about wordpress in this blog.

3 thoughts on “How to check the duplicate values from array using php

  1. Pingback: Tweets that mention How to check the duplicate values from array using php | Wordpressapi.com - Developer Code book -- Topsy.com

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>