I am trying to collect an array of data on the three criteria "city", "country", "region". The principle of operation is as follows: consider the user's IP and substitute it in json, after parsing 2 values āā("city", "country" (region unavailable)) But my code swears at array_merge. Tell me how to do this?
public static function GEO() { $ip = Route::clientIp(); $json = file_get_contents('http://geoip.nekudo.com/api/'.$ip); var_dump($json); $data = json_decode($json, true); $loc = [ 'city' => null, 'country' => null, 'region' => null ]; $location = array_merge($loc, $data); return $location; }