Answers for "remove same value from array php"

PHP
18

php remove duplicates from array

<?php
$fruits_list = array('Orange',  'Apple', ' Banana', 'Cherry', ' Banana');
$result = array_unique($fruits_list);
print_r($result);
?>
  
Output:

Array ( [0] => Orange [1] => Apple [2] => Banana [3] => Cherry )
Posted by: Guest on March-04-2020
1

remove duplicate values in array php

<?php
$list_programming_language = array('C#',  'C++', 'PHP', 'C#', 'PHP');
$result = array_unique($list_programming_language);
print_r($result);
?>
  
// ==> 'C#',  'C++', 'PHP'
Posted by: Guest on March-11-2021
1

how to remove duplicate values from an array in php

<?php
$input = array("a" => "green", "red", "b" => "green", "blue", "red");
$result = array_unique($input);
print_r($result);
?>

Array
(
    [a] => green
    [0] => red
    [1] => blue
)
Posted by: Guest on January-13-2021
0

how to remove duplicate values from a multidimensional array in php

We used this to de-duplicate results from a variety of overlapping queries.

$input = array_map("unserialize", array_unique(array_map("serialize", $input)));
Posted by: Guest on January-13-2021
0

php remove duplicates from array

<?php
$fruits_list = array('Orange',  'Apple', ' Banana', 'Cherry', ' Banana');
$result = array_unique($fruits_list);
print_r($result);
?>
Posted by: Guest on July-23-2021

Code answers related to "remove same value from array php"

Browse Popular Code Answers by Language