Skip to content
Advertisement

How to skip duplicate data in foreach loop

I need help in removing or skipping duplicate data from foreach array, i try to use array_unique() but it doesn’t help.

here’s my code.

JavaScript

if i have more than 2 products of same category in cart it repeat the same data, which should not.

this is what i get from print_r($term_prid)

JavaScript

How can i get

JavaScript

Advertisement

Answer

Save the IDs you’ve seen in an array, and check against that.

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