find array duplicates in two arrays 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:
- base64 to string pp
- current data in php
- console.log from functions php
- composer install laravel 7 not installing
- control string length php
- codeigniter delete record by id
- drupal/core 8.9.7 requires ext-dom * -> the requested PHP extension dom is missing from your system. composer install
- array_key_exists contains string
- Add the file php
- check if substring is present php
- debug php with print
- ext dom php
- find a specific word in a string and add another string after that specific word php
- date'G')
- '%r%i timeformat php
- .htaccess to remove index page
- boucle for php with data
- date funciton
- composer create-project --prefer-dist laravel/laravel blog
- artisan clear cahce
- factorial function php
- cache laravel
- Target class does not exist.
- clear cahce laravel