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 )
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 )
array_unique
<?php
$input = array("a" => "green", "red", "b" => "green", "blue", "red");
$result = array_unique($input);
print_r($result);
?>
Array
(
[a] => green
[0] => red
[1] => blue
)
array unique php
<?php
// Syntax: array_unique(array $array, int $flags = SORT_STRING): array
// Desc: Removes duplicate values from an array
$arr = Array("red", "red", "green", "blue", "blue", "white");
echo "<pre>";
print_r($arr);
echo "</pre> <br><br>";
$arrUnique = array_unique($arr);
echo "<pre>";
print_r($arrUnique);
echo "</pre> <br><br>";
/* -------- output -----------
Array
(
[0] => red
[1] => red
[2] => green
[3] => blue
[4] => blue
[5] => white
)
Array
(
[0] => red
[2] => green
[3] => blue
[5] => white
)
*/
?>
get duplicate value from array php
$arr = array(1, 4, 6, 1, 8, 9, 4, 6);
$unique = array_unique($arr);
$duplicates = array_diff_assoc($arr, $unique);
print_r($duplicates);
Array ( [3] => 1 [6] => 4 [7] => 6 )
remove duplicate value from array
let chars = ['A', 'B', 'A', 'C', 'B'];
let uniqueChars = [...new Set(chars)];
console.log(uniqueChars);
unique key value array php
$input = array_map("unserialize", array_unique(array_map("serialize", $input)));
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us