Skip to content
Advertisement

php Keeping only 1 date occurence in multi-dimensional array

I have this array with certain brand_ids, within these brands I have an array of dates in which a sale occured but these are based on the products in sale so they may appear multiple times on the same brand_id;

This is my array:

JavaScript

The code to generate this :

JavaScript

$saleDays is a 2D array of every sunday untill a certain year like so

JavaScript

All the duplicates stripped out and have it reduced to one unless the date is different per brand_id but I can’t seem to be able to produce that with array_unique, array_mapping and/or array_columns… How would I achieve the output below?

JavaScript

Advertisement

Answer

Use in_array as Tim Lewis proposed:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement