Jump to content

Disecting a String! arhh!


b00ker_b0y

Recommended Posts

Hello people!

 

in need of some help as i just cant get this thing to work!

 

I have a string i.e.    Scotland-UKs-heart-100-attack-hotspot-18216660

 

i need to remove the last bit of the string which is an id. so realy need to start from the back, then keep everything till its the dash, then remove everything before the dash.

 

At the moment i have this:

 

$page_name = preg_replace('/[^0-9]/','',$page_name);

 

this just removes everything except numbers from the string but then leaves with "10018216660" and it cant have the random 100 number in the middle to be included!

 

any ideas on where or what to look for in solve this?

 

Thanks for your time!

 

 

Link to comment
Share on other sites

arh, i am not sure if that will hold up!

 

as that seems to be counting the the "dashs -"? so say if the string is

 

"Scotland-UKs-heart-100-attack-hotspot-200-18216660" the its gonna pick up 200?

 

no matter how long the string might be i need it to take the last id?

Link to comment
Share on other sites

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.