I will need to read this file with PHP. I need to get the name of the city to add it inside a wordpress custom db table. At the moment I'm doing this
$cities = json_decode(require_once plugin_dir_path(__FILE__) . '/inc/cities.json');
foreach( $cities as $key => $val ){
var_dump($key, $val);
$wpdb->insert(
$tablename,
'city_name' => $val
);
}
But I'm not able to get the nome
field from the resulting array of the parsed json file. What is the correct way to parse the file and loop it to extract the needed data and pass it to the insert
function of WordPress?