PHP
- 3 ответа
- 0 вопросов
1
Вклад в тег
<?php
$array = array(1, "hello", 1, "world", "hello");
print_r(array_count_values($array));
?>
Array
(
[1] => 2
[hello] => 2
[world] => 1
)
<?php
$array = array(1, "hello", 1, "world", "hello");
$array_count = array_count_values($array);
$duplicates = [];
foreach ($array_count as $k=>$v){
if ($v > 1) $duplicates[] = $k;
}
print_r($duplicates);
?>
array = [
{
'header':'header1',
'contents':'contents1'
},
{
'header':'header2',
'contents':'contents2'
},
....
];