Answer the question
In order to leave comments, you need to log in
How to remove two identical array elements?
There is an array:
Array
(
[0] => Array
(
[e-fragnet] => http://mini.s-shot.ru/1024x2600/2048/png/?http://www.hltv.org/match/2299129-e-fragnet-hellraisers-global-offensive-champions-league-season-2
)
[1] => Array
(
[hellraisers] => http://mini.s-shot.ru/1024x2600/2048/png/?http://www.hltv.org/match/2299129-e-fragnet-hellraisers-global-offensive-champions-league-season-2
)
[2] => Array
(
[e-fragnet] => http://mini.s-shot.ru/1024x2600/2048/png/?http://www.hltv.org/match/2299129-e-fragnet-hellraisers-global-offensive-champions-league-season-2
)
[3] => Array
(
[hellraisers] => http://mini.s-shot.ru/1024x2600/2048/png/?http://www.hltv.org/match/2299129-e-fragnet-hellraisers-global-offensive-champions-league-season-2
)
[4] => Array
(
[envyus] => http://mini.s-shot.ru/1024x2600/2048/png/?http://www.hltv.org/match/2299130-envyus-csgl-sl-i-league-starseries-xiv
)
[5] => Array
(
[virtuspro] => http://mini.s-shot.ru/1024x2600/2048/png/?http://www.hltv.org/match/2299123-virtuspro-mousesports-cevo-professional-season-8-finals
)
[6] => Array
(
[mousesports] => http://mini.s-shot.ru/1024x2600/2048/png/?http://www.hltv.org/match/2299123-virtuspro-mousesports-cevo-professional-season-8-finals
)
[7] => Array
(
[virtuspro] => http://mini.s-shot.ru/1024x2600/2048/png/?http://www.hltv.org/match/2299123-virtuspro-mousesports-cevo-professional-season-8-finals
)
[8] => Array
(
[mousesports] => http://mini.s-shot.ru/1024x2600/2048/png/?http://www.hltv.org/match/2299123-virtuspro-mousesports-cevo-professional-season-8-finals
)
[9] => Array
(
[mousesports] => http://mini.s-shot.ru/1024x2600/2048/png/?http://www.hltv.org/match/2299122-mousesports-conquest-cevo-professional-season-8-finals
)
)
Answer the question
In order to leave comments, you need to log in
php.net/manual/ru/function.array-unique.php
Should help.
I wrote a comment under the post, I will duplicate the code here.
$input = []; // ваш массив
$result = [];
foreach($input as $elem)
$result[serialize($elem)] = $elem;
$result = array_values($result);
var_dump($result); // то что вам нужно
function myFilter($inp) {
$filter = function($carry, $item) {
if (false === array_search($item, $carry)) $carry[] = $item;
return $carry;
};
return array_reduce($inp, $filter, []);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question