purencool Posted August 25, 2011 Share Posted August 25, 2011 Hi phpfreaks I am trying to remove the first two numbers off a string. The string looks like 00-house or 23-water etc. I need to do a regex to remove them I have this so far but it does not work. $removed = preg_replace(array("/^\d[0-9]/", $folderItem); Any help would be great. Quote Link to comment https://forums.phpfreaks.com/topic/245663-removing-decimal-numbers/ Share on other sites More sharing options...
cags Posted August 25, 2011 Share Posted August 25, 2011 if you always wish to remove the first three characters you should probably consider substr. Quote Link to comment https://forums.phpfreaks.com/topic/245663-removing-decimal-numbers/#findComment-1261736 Share on other sites More sharing options...
silkfire Posted August 25, 2011 Share Posted August 25, 2011 If the numbers are always 2 characters long: $string = substr($string, 2); Quote Link to comment https://forums.phpfreaks.com/topic/245663-removing-decimal-numbers/#findComment-1261828 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.