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
https://forums.phpfreaks.com/topic/60748-disecting-a-string-arhh/
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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.