I am creating a function to set query vars as below.
function set_query_var(array $params)
{
$count = count($params);
$query_var = '?';
foreach ( $params as $key => $value)
{
$query_var .= $key . '=' . $value .
(($count > 1) ? '&' : NULL);
}
return $query_var;
}
Above function works fine but only issue is that, it is adding & to the end loop which I don't want.
How can I fix it?
http_build_query()