Skip to content
Advertisement

PHP inserting value only once

I am trying to add categories in a database. Things is the script is reading the categories from a product list, therefore there are duplicate values as it’d be like reading

PRODUCT NAME – DETAIL 1 – DETAIL 2 – CATEGORY

Rinse and repeat.

I have my code down and the insert works but it stops at the first product’s category value as if I put it out of my foreach loop.

JavaScript

I also want to point out my $c1 variable has multiple arrays. It’s not one multi-dimensional array.

So it’s like

Array { etc }

Array { etc }

Array { etc }

Array { etc }

Array { etc }

Advertisement

Answer

I fixed it by using this function and using my same .csv file as a multi-dimensional array. Before I couldn’t operate with it due to my output being a fake array, it was recognized as string if anything. With this I could easily operate on the sub-arrays through the standard array PHP functions shortly after.

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