Вот мой сценарий:
Код: Выделить всё
public function getWeatherConfig($lat =35.683, $lon=139.778, $elevation=10){
$weatherConfig_General = [
'latitude' => $lat,
'longitude' => $lon,
'elevation' => $elevation,
'hourly' => 'test',
'daily' => 'YYY',
'current' => 'XXX',
'temperature_unit' => null,
];
$count = count($weatherConfig_General);
$i = 1;
$query_string = '';
// Loop through the variables and check their values
foreach ($weatherConfig_General as $varName => $value) {
if ($value or $i < $count) {
$query_string .= $varName.'='.$value.'&'; // Add the variable name to the trueVars array if it's true
} else {
$query_string .= $varName.'='.$value; // do not add & on the last value.
}
$i++;
}
echo '
Подробнее здесь: [url]https://stackoverflow.com/questions/79112742/why-is-php-changing-my-key-to-unknow-characters-how-do-i-prevent-php-from-doing[/url]