find array duplicates php
function has_dupes($array) {
$dupe_array = array();
foreach ($array as $val) {
if (++$dupe_array[$val] > 1) {
return true;
}
}
return false;
}$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:
- check if word belongs in string
- clear cache in php artisan
- artisan migrate one table
- create seeds laravel
- array get only the value without duplicate
- Decode from Base64 format php
- centos excecutable php
- dat day in php
- download html content from url php
- PHP Startup: Unable to load dynamic library 'curl'
- create folder php en linux centos 7
- find a file in php
- associative array rev in php
- SET DEFAULT hide title astra wordpress
- encode and decode int to base64 using php
- composer php version command
- Get last id in laravel
- console print in php
- bulk seed in laravel with update or create
- ext-dom php 7.4 ubuntu
- error reporting 0 in hph
- clear cache manually laravel
- List all folder in pHP
- #1146 - Table 'phplessons.super' doesn't exist