mjahkoh Posted September 14, 2011 Share Posted September 14, 2011 Am looking forward to removing all the numeric characters upto and including the leading "/" in 90/_featuredarticles/2011/12 Regards Link to comment https://forums.phpfreaks.com/topic/247129-remove-some-characters-from-a-string/ Share on other sites More sharing options...
voip03 Posted September 14, 2011 Share Posted September 14, 2011 You can use. •preg_replace() •substr() Link to comment https://forums.phpfreaks.com/topic/247129-remove-some-characters-from-a-string/#findComment-1269225 Share on other sites More sharing options...
AyKay47 Posted September 14, 2011 Share Posted September 14, 2011 there a several ways to do this you'll find.. I will give one way.. $string = "90/_featuredarticles/2011/12"; $offset = strpos("/",$string); $new_string = substr($string,$offset); Link to comment https://forums.phpfreaks.com/topic/247129-remove-some-characters-from-a-string/#findComment-1269226 Share on other sites More sharing options...
mjahkoh Posted September 14, 2011 Author Share Posted September 14, 2011 not working Link to comment https://forums.phpfreaks.com/topic/247129-remove-some-characters-from-a-string/#findComment-1269242 Share on other sites More sharing options...
AyKay47 Posted September 14, 2011 Share Posted September 14, 2011 for some reason strpos() is not locating the first "/", honestly im not sure why... so lets use the reg ex method instead.. <?php $string = "90/_featuredarticles/2011/12"; $pattern = "~[0-9]*/(.*)~i"; preg_match($pattern,$string,$matches); print $matches[1]; //ouputs _featuredarticles/2011/12 ?> Link to comment https://forums.phpfreaks.com/topic/247129-remove-some-characters-from-a-string/#findComment-1269273 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.