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 Quote 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() Quote 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); Quote 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 Quote 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 ?> Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.