baiju Posted October 9, 2006 Share Posted October 9, 2006 hi how to retrive a only number from string..$val='3157100325,878042,379,1';i need only numbersout shoul be 31571003258780423791;that means i need only integer valuesplease help me out Link to comment https://forums.phpfreaks.com/topic/23414-retreive-integer-from-string/ Share on other sites More sharing options...
tomfmason Posted October 9, 2006 Share Posted October 9, 2006 I think that you want explode. Like this.[code=php:0]$val='3157100325,878042,379,1';$newval = explode(',', $val);[/code]Hope that helps,Tom Link to comment https://forums.phpfreaks.com/topic/23414-retreive-integer-from-string/#findComment-106180 Share on other sites More sharing options...
baiju Posted October 9, 2006 Author Share Posted October 9, 2006 that value contain not only commas may be character also will come that is problem.. Link to comment https://forums.phpfreaks.com/topic/23414-retreive-integer-from-string/#findComment-106181 Share on other sites More sharing options...
AndyB Posted October 9, 2006 Share Posted October 9, 2006 [code]$whatever = "(123) 456-7890";$whatever_clean = preg_replace('/[^0-9]/','',$whatever);echo $whatever_clean;[/code] Link to comment https://forums.phpfreaks.com/topic/23414-retreive-integer-from-string/#findComment-106215 Share on other sites More sharing options...
brown2005 Posted October 9, 2006 Share Posted October 9, 2006 Had a look at Andy's code works fine.. ill keep it for further reference.. very useful Link to comment https://forums.phpfreaks.com/topic/23414-retreive-integer-from-string/#findComment-106217 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.