fdjason Posted May 3, 2010 Share Posted May 3, 2010 What does this function do and more specifically, what does /[^0-9]/ mean? function CleanNumber($UserInput) { $pattern = "/[^0-9]/"; //replace everything except 0-9 $UserInput = preg_replace($pattern, "", $UserInput); return substr($UserInput, 0, 6); } Link to comment https://forums.phpfreaks.com/topic/200565-what-does-this-function-mean/ Share on other sites More sharing options...
Ken2k7 Posted May 3, 2010 Share Posted May 3, 2010 It strips out all non-digit characters and return a string of the first 6 numbers. /[^0-9]/ is a regular expression. It matches all non-digit characters. The 0-9 just means numbers 0 to 9. The ^ is not. Link to comment https://forums.phpfreaks.com/topic/200565-what-does-this-function-mean/#findComment-1052471 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.