UrbanDweller Posted October 20, 2011 Share Posted October 20, 2011 Hey, Im trying make a way to check an input to make sure it only consists of "1,2,3,4,5,6,7,8,9,0 and . " I thought i could explode the number and check it to an array that has "1,2,3,4,5,6,7,8,9,0 and . " I havent worked with arrays before so i dont quite know how they work or to go about this? Any ideas cause im sure im not the first to ask for something like this Thanks Quote Link to comment https://forums.phpfreaks.com/topic/249442-check-integer-explode-to-an-array/ Share on other sites More sharing options...
bh Posted October 20, 2011 Share Posted October 20, 2011 hi, had you about http://php.net/manual/en/book.pcre.php? what is the type of the input? float? than maybe http://www.php.net/manual/en/function.is-float.php Quote Link to comment https://forums.phpfreaks.com/topic/249442-check-integer-explode-to-an-array/#findComment-1280772 Share on other sites More sharing options...
silkfire Posted October 20, 2011 Share Posted October 20, 2011 It depends what you want to do: 1. Do you want to control the user input and return a "yes" or "no" whether it contains forbidden characters? 2. Or do you want to remove all forbidden characters automatically without letting the user know? Quote Link to comment https://forums.phpfreaks.com/topic/249442-check-integer-explode-to-an-array/#findComment-1280774 Share on other sites More sharing options...
bh Posted October 20, 2011 Share Posted October 20, 2011 @silkfire: "to check an input to make sure it only consists" Quote Link to comment https://forums.phpfreaks.com/topic/249442-check-integer-explode-to-an-array/#findComment-1280775 Share on other sites More sharing options...
silkfire Posted October 20, 2011 Share Posted October 20, 2011 Then create a regex with preg_match Quote Link to comment https://forums.phpfreaks.com/topic/249442-check-integer-explode-to-an-array/#findComment-1280781 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.