check array for 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:
- bulk seed in laravel with update or create
- How to use mbstring on Heroku (PHP)
- date("Y")
- create project via composer
- date with current time in php
- artisan composer install
- check if array contains a key php
- decode a nested JSON with php
- [WAR] df (lib\peer.php:164) file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed
- cache clear in code php laravel
- apache 2 lib php 7.4
- display image in php from folder
- .net base64 encode decode in php
- codeigniter insert get last id and increment by one value
- detecting right click on windows
- check if word belongs in string
- date and time function php
- <?php trim($_POST["data"]); ?>
- exception handling in php with example
- curl multi exec
- check version of php using composer
- datetime php create from timestamp
- command not found: laravel
- date month php