$res = '';
foreach ($params as $key => $value) {
$res .= $key.'='.$value;
}
$arr = array("hello" => "world", "how" => "are", "you" => "dude");
echo str_replace(["&", "?"], '', http_build_query($arr));
<?php
$arr = array("hello" => "world", "how" => "are", "you" => "dude");
$result = array_reduce(
array_keys($arr),
function($acc, $key) use ($arr) {
return $acc . $key . '=' . $arr[$key];
},
''
);
echo $result;