<?php
$string = 'http://example.com/profile.php?id=9999&refid=22';
$url = parse_url($string);
parse_str($url['query'], $get);
unset($get['refid']);
$url['query'] = http_build_query($get);
echo $url['scheme'] . '://' . $url['host'] . $url['path'] . '?' . $url['query'];