How to remove duplicate values from a PHP Array?

Member

by sidney , in category: Technology , 3 years ago

How to remove duplicate values from a PHP Array?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by braeden , 3 years ago

You can use library function array_unique() for removing duplicated values for an array. Here is syntax to use it.

1
2
3
4
<?php
	$a=array("a"=>"home","b"=>"town","c"=>"town","php");
	print_r(array_unique($a));
?>