array_unique in php
<?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 ) function has_dupes($array) {
$dupe_array = array();
foreach ($array as $val) {
if (++$dupe_array[$val] > 1) {
return true;
}
}
return false;
}$input = array_map("unserialize", array_unique(array_map("serialize", $input)));let chars = ['A', 'B', 'A', 'C', 'B'];
let uniqueChars = [...new Set(chars)];
console.log(uniqueChars);
<?php
$input = array("a" => "green", "red", "b" => "green", "blue", "red");
$result = array_unique($input);
print_r($result);
?>
Array
(
[a] => green
[0] => red
[1] => blue
)$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 )
Also in PHP:
- curl multi exec
- Laravel DB Cache
- equivalent console.log in php
- PHP Numbers
- ?? null laravel
- Installation request for pokemon-tcg/pokemon-tcg-sdk-php ^1.2 -> satisfiable by pokemon-tcg/pokemon-tcg-sdk-php[1.2.0]
- ->with()->where laravel
- array_key_exists(
- detecting right click on windows
- Created Migration: laravel
- authenticate user with phone laravel
- Laravel 7 do not see my new added seeder
- clear cache routes laravel
- check index array php
- 500 error coming on laravel site
- convert byte to megabyte php
- PHP check if 2 words given
- check if number doesn't divide exactly by 3 php
- file_get_contents(): SSL: The operation completed successfully but file_get_contents(http://www.b2bsoftwareking.com): failed to open stream: No connection could be made because the target machine actively refused it. in
- add 1 day to date using php
- create new laravel project composer
- bu7scador con laravel
- delete file using php
- composer create project laravel 7