function http_build_query_new($data, $prefix = null, $sep = '', $key = '', $question_mark = 0, $comma = 0, $current_url = 0)
{
    $ret = array();
    foreach ((array) $data as $k => $v) {
        $k = urlencode($k);
        if (is_int($k) && $prefix != null) {
            $k = $prefix . $k;
        }
        if (!empty($key)) {
            #$k = $key."[".$k."]";
            # making it more like the original php
            $k = $key . "[]";
        }
        if (is_array($v) || is_object($v)) {
            array_push($ret, http_build_query_new($v, "", $sep, $k));
        } else {
            # added the if so that blank entries dont show up
            if (urlencode($v)) {
                array_push($ret, $k . "=" . urlencode($v));
            }
        }
    }
    if (empty($sep)) {
        $sep = ini_get("arg_separator.output");
    }
    $return_data = implode($sep, $ret);
    if ($comma) {
        if ($return_data) {
            $return_data .= "&";
        }
        if ($question_mark) {
            $return_data = "?" . $return_data;
        }
    } else {
        if ($question_mark and $return_data) {
            $return_data = "?" . $return_data;
        }
    }
    if ($current_url) {
        if ($current_url == 1) {
            preg_match("/([^\\/]+)\$/i", $_SERVER['PHP_SELF'], $results);
            $return_data = $results[1] . $return_data;
        } else {
            $return_data = $current_url . $return_data;
        }
    }
    return $return_data;
}
//      $query_string = preg_replace( "/&start=\d+/", "", "&" . $_SERVER['QUERY_STRING'] . "&" );
//      $query_string = preg_replace( "/\w+=&/", "&", $query_string . "&" );
//      $query_string = preg_replace( "/^&+/", "", $query_string );
//      $query_string = preg_replace( "/&+$/", "", $query_string );
//      $query_string = preg_replace( "/&+/", "&", $query_string );
if ($form_query_variables) {
    $FORM1 = $FORM;
    foreach ($FORM1 as $key => $value) {
        if (is_array($value)) {
            $value = join(",", $value);
        }
        $paginate_query_string_variables[$key] = $value;
    }
} else {
    if (!$paginate_query_string_variables) {
        if ($server_query_string) {
            parse_str($_SERVER['QUERY_STRING'], $paginate_query_string_variables);
        } else {
            $url_parse = parse_url($_SERVER['REQUEST_URI']);
            parse_str($url_parse['query'], $paginate_query_string_variables);
        }
    }
}
unset($paginate_query_string_variables['start']);
if ($paginate_query_string_variables_to_remove) {
    foreach ($paginate_query_string_variables_to_remove as $key) {
        unset($paginate_query_string_variables[$key]);
    }
}
$query_string = http_build_query_new($paginate_query_string_variables, "", "&");