Hello, I cannot figure this out... I will leave out most of the code to not confuse you, but I have it almost working so I am just missing something. I have two arrays, one that contains the IDS that I want correctly. Here is the first array when I print it out:
Array ( [0] => 3 [1] => 9 [2] => 11 )
Perfect, it displays the IDS 3, 9, and 11 like it should. Now here is my second array when printed out:
Array ( [0] => name value [1] => maker value [2] => year value )
That works too. name value, maker value, and year value are the results. I tried using an array_merge on those two arrays hoping that it will turn it into
3 => 'name value', 9 => 'maker value', 11 => 'year value'
For some reason the result I get when I merge these two arrays is:
Array ( [0] => 3 [1] => 9 [2] => 11 [3] => name value [4] => maker value [5] => year value )
It does merge them, but as separate array values. So when I use my foreach() to insert the values into a DB, I get this as a result:
INSERT INTO fields_table (field_id, field_value) VALUES ('0', '3') INSERT INTO fields_table (field_id, field_value) VALUES ('1', '9') INSERT INTO fields_table (field_id, field_value) VALUES ('2', '11') INSERT INTO fields_table (field_id, field_value) VALUES ('3', 'name value') INSERT INTO fields_table (field_id, field_value) VALUES ('4', 'maker value') INSERT INTO fields_table (field_id, field_value) VALUES ('5', 'year value')
What do I do to make the first values equal the second values please? Thanks.
EDIT
HAHA I finally figured this out when creating this topic! I have to use array_combine() instead of array_merge it works perfect now Nevermind I solved it!