I am trying to insert a JSON Array (objects?!) into mysql with php. When the data comes through as Rows, I can handle that! However, I had to export the array in a different manner, and now I'm not able to figure it out. After $array=json_decode($posted,true);, my array looks like:
(
[0] => Array
(
[0] => Allen, test
[1] => Anderson, Jayson
[2] => Barrett, Kayla
[3] => Bennett, Amira
)
[1] => Array
(
[0] => [email protected]
[1] => [email protected]
[2] => [email protected]
[3] => [email protected]
)
)
How can I get this into a foreach loop that outputs:
insert into table (name, email) values("Allen, test","[email protected]")
insert into table (name, email) values("Anderson, Jayson","[email protected]")
... etc?
When the data was in a 'row' format, it was easy for me ..
foreach($array as $row)
{
$query="insert into table (name, email) values(\"$row[0]\",\"$row[1]\")";
$doit = mysqli_query($con,$query);
}
But now that the array is not coming through in rows, I cant quite figure it out.
foreachfor aforloop.)