1

After I use array_unique() on an array, when I var_dump() the array, it still has the same content, with duplicates:

array(21) { 
[0]=> string(10) "tricou_CRS" 
[1]=> string(10) "tricou_CRM" 
[2]=> string(11) "tricou_CRXL" 
[3]=> string(10) "tricou_CBM" 
[4]=> string(10) "tricou_CBL" 
[5]=> string(10) "tricou_CWS" 
[6]=> string(11) "tricou_CWXL" 
[7]=> string(10) "tricou_CRS" 
[8]=> string(10) "tricou_CRM" 
[9]=> string(11) "tricou_CRXL" 
[10]=> string(10) "tricou_CBM" 
[11]=> string(10) "tricou_CBL" 
[12]=> string(10) "tricou_CWS" 
[13]=> string(11) "tricou_CWXL" 
[14]=> string(10) "tricou_CRS" 
[15]=> string(10) "tricou_CRM" 
[16]=> string(11) "tricou_CRXL" 
[17]=> string(10) "tricou_CBM" 
[18]=> string(10) "tricou_CBL" 
[19]=> string(10) "tricou_CWS" 
[20]=> string(11) "tricou_CWXL" }

Which obviously has some duplicates. Now, there's not much code that could help, really, because it's just

array_unique($myarr);
var_dump($myarr);

So, what am I missing there? Shouldn't array_unique() remove the duplicates? Both the type and the content is the same in many of the array's positions.

1 Answer 1

10
$uniquearr = array_unique($myarr);
var_dump($uniquearr);

Always read docs first

array_unique

Return Values

Returns the filtered array.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.