Home › Forums › Back End › PHP – Remove anything after the last / › Re: PHP – Remove anything after the last /
September 14, 2011 at 5:37 am
#87148
chrisburton
Participant
@KarimCossutti – I just found this on another site
string input = "http://www.somesite.com/somepage.aspx?whatever";
int index = input.LastIndexOf("/");
if (index > 0)
input = input.Substring(0, index); // or index + 1 to keep slash