find 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:
- extend php maximum execution time
- error correction in qr code php
- date time from timestamp php
- console log function php
- dateformat php Y-m-d
- 01 july 2020 php date format
- add all error in pph
- exist in string php
- error_reporting in php.ini file
- check string in string php
- M-d h:i:a
- extract contact page url php
- Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:
- In Connection.php line 1262: Class 'PDO' not found
- day of the week th usig php
- $b = strpos($line,$start); $a = strpos($line,$end,$b+9);
- error reporting ini set dusplay errors
- create symfony project
- <?php header('Location: /index');
- check if a key exists in php array
- disable errors in php
- character length in php
- You want to develop a Laravel application on your Windows machine. For this, you installed the Laravel framework on your system. In which of the following scenarios, Laravel will not run on your system?
- class name laravel