duplicate values 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:
- composer php version command
- date du joure n php
- Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) composer
- download html content from url php
- error messaging php
- SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767
- fetch today data in php
- Customer::insert([ 'customer_name' => $request->customer name, 'customer mobile'=> $request->customer mobile, 'user_id'=>Auth::user()->id, 'created_at'=> Carbon::now() ]);
- add days to date in php
- dispaly object type php
- date time formatting php
- /phpspreadsheet 1.15.0 requires ext-dom * centos
- datetime to string php
- datetime php difference in days
- datatype checking in php
- add no of days to date php
- clear cache swr
- Customer::insert([ 'customer_name' => $request->customer_name, 'customer_mobile'=> $request->customer_mobile, 'user_id'=>Auth::user()->id, 'created_at'=> Carbon::now() ]);
- date U
- date format change in laravel blade
- check array key exists php js
- Allowed memory size of 1610612736 bytes exhausted larave lvalet composer
- command to create seed file in laravel
- fetch values and display in bar chart php mysql