D
D
Dmitry2020-10-22 09:49:46
Yii
Dmitry, 2020-10-22 09:49:46

Why do brand IDs fly off after applying array_diff?

Hello, there is a list of brands in the filter, I form links for each brand like this namesite.com/cat/category-odin?brand-1,2, etc. I do it with manual concatenation

'brand' => implode(',', array_merge(explode(',', $brands), [$brand->id])

I decided to use array_diff instead of "array_merge" to remove duplicate values ​​from the link, and here is the problem, when using array_diff brand IDs fly off, I select a brand, and this ID that is selected to apply to other brands, tell me, please, what could be the problem?
PS Or tell me how to properly remove duplicate values ​​in the link (color=black&color=brown)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question