wiegs Posted March 17, 2006 Share Posted March 17, 2006 I need to figure out a way to extract only numberic data from one field into another. original data:test2345.gifresults I would like:2345please help! I have spent way to much time trying to figure this out. Quote Link to comment https://forums.phpfreaks.com/topic/5133-need-a-little-help-here/ Share on other sites More sharing options...
hitman6003 Posted March 17, 2006 Share Posted March 17, 2006 Something like this should work:[code]$s = "test2345.gif";function getnumbers($str) { $ret = ""; for ($i = 0; $i <= strlen($str); $i++) { if (is_numeric($str{$i})) { $ret .= $str{$i}; } } return $ret;}echo getnumbers($s);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/5133-need-a-little-help-here/#findComment-18235 Share on other sites More sharing options...
wiegs Posted March 17, 2006 Author Share Posted March 17, 2006 [!--quoteo(post=355806:date=Mar 16 2006, 09:50 PM:name=hitman6003)--][div class=\'quotetop\']QUOTE(hitman6003 @ Mar 16 2006, 09:50 PM) [snapback]355806[/snapback][/div][div class=\'quotemain\'][!--quotec--]Something like this should work:[code]$s = "test2345.gif";function getnumbers($str) { $ret = ""; for ($i = 0; $i <= strlen($str); $i++) { if (is_numeric($str{$i})) { $ret .= $str{$i}; } } return $ret;}echo getnumbers($s);[/code][/quote]this worked great. thanks! Quote Link to comment https://forums.phpfreaks.com/topic/5133-need-a-little-help-here/#findComment-18238 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.