Jump to content

remove duplicates in array


carlozdre

Recommended Posts

I have an array called $lineArray.

 

If I do a var_dump on $lineArray[5] I will get a few hundreds entries, something like:

 

string(9) "something"

string(13) "somethingelse"

string(9) "notreally"

string(9) "something"

 

I need to move/copy all those lines into another array but without the duplicates, so I will only have one 'something' in the new array, not have it twice as per the above example.

 

I've tried:

 

    $pagesWithErrors = array();
    $pagesWithErrors[] = $lineArray[5];
    $pagesWithErrors = array_unique($pagesWithErrors);
 
But it doesn't work for me.
 
How do I do it?

 

Link to comment
https://forums.phpfreaks.com/topic/284070-remove-duplicates-in-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.