array unique values
function getNotUnique(array) {
var map = new Map();
array.forEach(a => map.set(a, (map.get(a) || 0) + 1));
return array.filter(a => map.get(a) > 1);
}
console.log(getNotUnique([1, 2, 2, 4, 4])); //[2, 2, 4, 4]
console.log(getNotUnique([1, 2, 3] )); //[]<?php
$input = array("a" => "green", "red", "b" => "green", "blue", "red");
$result = array_unique($input);
print_r($result);
?>
Array
(
[a] => green
[0] => red
[1] => blue
)var array3 = array1.filter(function(obj) { return array2.indexOf(obj) == -1; });arr = [2, 2, 2, 1, 3, 3, 3,3, 4, 5];
arr = arr.sort().filter((item,i)=>!(arr[i] == arr[i+1] || arr[i-1]==arr[i]));
// this will remove all item which are repeating more then one
console.log(arr);
// [1, 4, 5]
Also in PHP:
- check key exists in associative array in php
- PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Sp ecified key was too long; max key length is 1000 bytes")
- check how much letter php
- add validation for webp image in laravel
- creat laravel project
- echo ternary php
- date time format list php
- create custom pagination in laravel 7 for api
- base64 php encode decode
- Uncaught RedisException: Redis server went away in
- dynamic carousel bootstrap php
- find a word in srting php
- apache php e_warnings e_notice off
- disable timestamp laravel
- artisan cache clear
- add checkbox in server side datatable laravel
- crete new project in laravel
- file_get_contents openssl error
- clear laravel.log
- decode ' php
- codeigniter get insert iditer print last query
- codeigniter id of last insert
- @ production: `cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js` npm ERR! Exit status 1
- How to check beautify json result using php