$url_parse_arr = parse_url('https://vk.com/test');
echo $url_parse_arr['path'] // test
$url_parse_arr = parse_url('https://vk.com/id100');
echo $url_parse_arr['path'] // id100
if (preg_match('/id\d+/ui', $url_parse_arr['path'])){
$url_parse_arr['path'] = str_replace('id', '', $url_parse_arr['path'] ); // 100
}