How to remove part of the string from one character to another in php -


i have url string

http://mydomain.com/status/statuspages/state/stack:3/my_link_id:1#state-9 

i want remove my_link_id:1 string. know can use string replace function

$goodurl = str_replace('my_link_id:1', '', $badurl); 

but problem is, integer part dynamic. mean in my_link_id:1 1 dynamic. id of link , can 0 number. want remove my_link_id:along dynamic number string.

what think should remove part of string last / #. how can that?

you can use regular expressions:

$goodurl = preg_replace('/(my_link_id:[0-9]+)/ig', '', $badurl); 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -