Jump to content

Remove Array Duplicates Without Merging


matthewtbaker

Recommended Posts

Hi,

 

Please could you point me in the right direction...

 

 

I want to compare the two arrays (below) and then remove any duplicate values from my temporary array $arrTemp. In this instance the word 'array' will be removed from $arrTemp as it exists in $arrMain.

 

$arrMain = ('the' , 'main' , 'array');

$arrTemp = ('some' , 'array' , 'stuff');

 

 

I have found solutions which merge the two but this doesn't suit what I need.

 

array_unique(array_merge($arrMain, $arrTemp));

 

 

If you could please provide a solution that would be great. I'd like to avoid loops if possible.

 

Matt

Link to comment
https://forums.phpfreaks.com/topic/269667-remove-array-duplicates-without-merging/
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.