Jump to content

Recommended Posts

Good day!

 

I've tried a few routes but haven't managed a simple approach. Ideally I'd like to use one of PHPs built in functions to make the code cleaner and easier to follow.

 

Basically I need to remove anything after a defined number of occurrences of a character from the example string below;

 

 

$iLevels = 2;

$sUrl = http://www.example.com/products/entertainment/films/dvd/page.html

 

So in this case I need to remove anything after the second to last forward slash, deleting dvd/page.html. The number of forward slashes to remove is variable therefore a flexible solution is needed.

 

Thanks for your help/advice in advance!

 

Matt

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.