detect duplicate in array 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:
- excerpt custom post type
- codeigniter form_validation email
- php + server + databse
- array_key_first not works
- ddev laravel setup
- console.log from php
- check the php version in ubuntu
- 500 Server Error laravel when sign up
- auto generate password in php on button click
- Your Composer dependencies require the following PHP extensions to be installed: fileinfo
- dmY PHP
- $db php
- date("H:i:s"); is js or php
- array_unique trong php
- TEXT UPPER PHP
- _______ is used to execute laravel project
- date format with t and z php
- comannd for rout in laravel
- 500 server error laravel 7
- download laravel for php 5.6 windows
- <?php ini_set('display_errors', 'On'); error_reporting(E_ALL); $finalIURL =
- ClearCache laravel
- error enable php
- 3d array search