How to remove duplicate values from Array in PHP?

Today now in this post i will show you How to remove duplicate values from Array in PHP? This is very easy to delete the duplicate values from any PHP Array. But sometimes new developers are confuse about how to remove. But in PHP provide a pre-define function as array_unique that is help us to remove the duplicate values from Array.

By using array_unique() we can get only the unique value from array. So, now we can see in the bellow example i have one value two times but when i will use the array_unique() then it will return the only unique value as the bellow output:

Example:
$myArray = [11,34,56,78,34];
$myArrayNew = array_unique($myArray);
print_r($myArrayNew);
Output:
Array
(
    [0] => 11
    [1] => 34
    [2] => 56
    [3] => 78
)

Read Also: How to convert file extension using CloudConvert in laravel?

Thanks for read. I hope it help you. For more you can follow us on facebook

About Shahriar Sagor

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Shahriar Sagor →