I got an array which is a result from webscraping that comes like this:
array:
[
'line1',
'line2',
'line3',
'linen'..
]
I have to insert this data to MySQL. The thing is, each 10 lines of the array is one line of MySQL table.
So I have to join line1 to line10 - line11 to line20 and so on..
I tried to create a new array with keys each 10 iterations like this:
arrayFinal.push({
key: counter,
value: array[i]
});
But wasn't the results I expected.
How can achieve this?
- Update:
Let's say this is the array (or object idk) that i recieve:
array:
[
'id',
'name',
'age',
'address',
'id',
'name',
'age',
'address'
]
There's non key that identifies which field is which. I just put the fields like 'id' so you can understand. Now, i have to separate this array to insert into mysql. You see a pattern each 4 lines, right?
'insert into mysql (id, name, age, address) values ?'