$url = "https://www.youtube.com/channel/UCgExa-5JOkNAwSUuGSjRhtA/"; echo preg_replace('~[/]*$~', '', $url);