I have an API request and I need it to put in MySQL DB
{
"channel": {
"id": 456221,
"name": "CURRENT VALUES",
"description": "Sensor Current ACS712 Values",
"latitude": "0.0",
"longitude": "0.0",
"field1": "Current",
"created_at": "2018-03-22T13:13:01Z",
"updated_at": "2018-03-28T12:41:13Z",
"last_entry_id": 37
},
"feeds": [
{
"created_at": "2018-03-28T12:41:13Z",
"field1": "4.98534"
}
]
}
while I use foreach loop to retrieve values "feeds fields1"
$url = "https://api-url";
$string = file_get_contents($url);
$arr = json_decode($string, true);
foreach($arr ["feeds"] as $item){
$entry_id = $item['entry_id'];
$field1 = $item['field1'];
mysql_query("INSERT INTO temperature (id_entry, field1) VALUES('$entry_id', '$field1')") or die (mysql_error());
}
My aim is to get the "channel id" and "feeds field1" into an array and then use them in a foreach loop.