how to get arabic results in location weather search form " the api support arabic lang "
i have the weather results with english lang just when i input arabic city neme i have no results when i replace the location name in link with arabic city name directly i have all inf i need but when i use the search form i have the results with en lang the code below .. what can i do to get the results with ar lang !!
<meta charset="utf-8">
<main class="container text-center"
<h1 class="display-1">حالة الطقس</h1>
<form class="form-inline" method="post">
<div class="form-group mx-auto my-5">
<label class="sr-only" for="location">يرجى ادخال موقعك</label>
<input tupe="text" class="form-control" id="location" placeholder="location" name="location" size="100%">
<button class ="btn btn-primary" type="submit">ابحث الان</button>
</div>
</form>
----
$location = htmlentities($_POST['location']);
$location = str_replace(' ', '+', $location);
$geocode_url = 'https ://geocoder.api.here.com/6.2/geocode.json?searchtext='.$location.'&app_id=XXX&app_code=XXX';
$location_data = json_decode(file_get_contents($geocode_url));
Apparently this was due to the fact that the dynamically inserted value was not properly URL-encoded, so the fix is to change
searchtext='.$location.'
to
searchtext='.urlencode($location).'
When you test such a URL by directly inputting it into your browser address bar, the browser usually applies missing encoding where necessary on its own - but other systems don’t necessarily do that, so you need to apply it yourself.