Remove duplicate values using PHP Example

Today, We want to share with you Remove duplicate values using PHP.
In this post we will show you PHP : array_unique() function, hear for find and Remove duplicate values in array php we will give you demo and example for implement.
In this post, we will learn about PHP Remove duplicate elements from Array with an example.

Remove duplicate values using PHP Example

There are the Following The simple About Remove duplicate values From An Array using PHP Full Information With Example and source code.

Making The Interface

index.php


	
	<title>How to remove All the duplicate values from an array in PHP - infinityknow.com</title>
		
		
	

	<nav class="navbar navbar-default">
		<div class="container-fluid">
			<a class="navbar-brand" href="<a href="https://infinityknow.com">infinityknow</a>
</a>		</div>
	</nav>
	<div class="col-md-3"></div>
	<div class="col-md-6 well">
		<h3 class="text-success">PHP - Remove Duplicate Values From An Array</h3>
		<hr style="border-top:2px dotted" />
		<div class="col-md-3"></div>
		<div class="col-md-6">
			<form>
				<div>
					<label>Array Content</label>
					<div id="data_response"></div>
				</div>
				<button type="button" class="btn btn-success" id="delete_duplicate"><span class="glyphicon glyphicon-trash"></span> Remove Duplicate</button>
			</form>
		</div>
	</div>

<a href="http://js/jquery-3.2.1.min.js">http://js/jquery-3.2.1.min.js</a>
<a href="http://js/script.js">http://js/script.js</a>

Making PHP Script

data.php

<?php
	$array = array("krunal", "Jupiter", "jaydeep", "Earth", "Saturn", "Venus", "jaydeep", "Venus",  "Mercury", "krunal", "Uranus");
	if(ISSET($_POST['res'])){
		echo "<pre>";
		print_r($array);
		echo "</pre>";
	}
 
?>

remove.php

<?php
	$array = array("krunal", "Jupiter", "jaydeep", "Earth", "Saturn", "Venus", "jaydeep", "Venus",  "Mercury", "krunal", "Uranus");
	if(ISSET($_POST['res'])){
		$data_response = array_unique($array);
		echo "<pre>";
		print_r($data_response);
		echo "</pre>";
	}
 
?>

Making jQuery Script

script.js

$(document).ready(function(){
 
	displayData();
 
	function displayData(){
		$.ajax({
			url: "data.php",
			type: "POST",
			data: {res: 1},
			success: function(data){
				$('#data_response').html(data);
			}
		});
	}
 
	$('#delete_duplicate').on('click', function(){	
		$.ajax({
			url: "remove.php",
			type: "POST",
			data: {res: 1},
			success: function(data){
				$('#data_response').html("<h4>Removing...</h4>");
				$('#delete_duplicate').attr('disabled', 'disabled');
				setTimeout(function(){
					$('#delete_duplicate').removeAttr('disabled');
					$('#data_response').html(data);
				}, 3000);
			}
		});
	});
});

jQuery 15 Powerful Tips and Tricks for Developers and Web Designer

Read :

READ :  PHP mysql with Connecting to Database Using AngularJS

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about find and Removes All the duplicate values using PHP.
I would like to have feedback on my Infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

https://pakainfo.com/

Add a Comment

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