How to reference a specific array element while iterating other elements of the same array and executing INSERT queries
I have the following input array:
$arr = [
"quote_id" => "1",
"ONE" => "2018-03-12",
"TWO" => "2018-02-12",
"THREE" => "2018-01-12",
"FOUR" => "2017-12-12"
];
and I need to transform to the following output:
[
"quote_id" => "1",
"ONE" => "2018-03-12"
],
[
"quote_id" => "1",
"TWO" => "2018-02-12"
],
[
"quote_id" => "1",
"THREE" => "2018-01-12"
],
[
"quote_id" => "1",
"FOUR" => "2017-12-12"
]
The idea is to insert a record in the DB per each COLUMN (ONE, TWO, ...) so I end up with:
INSERT INTO table id=1, value="2018-03-12"
INSERT INTO table id=1, value="2018-02-12"
INSERT INTO table id=1, value="2018-01-12"
INSERT INTO table id=1, value="2017-12-12"