Alicia Posted January 20, 2010 Share Posted January 20, 2010 Hi guys, Can some guru advise how I can write a script to accomplish this : when user key in 2 numbers such as 23, the script will check all numbers in the range of (0,999) and display only numbers with 23 such as ---- > 023,123,223,323,423,523,623,723,823,923 (with permutation) Please advise. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/189193-matching/ Share on other sites More sharing options...
Felex Posted January 20, 2010 Share Posted January 20, 2010 $UserKey = 23; $MatchedArray = array(); for($i = $UserKey; $i <= 999; $i++) { if((($i - $UserKey) % 10) == 0) // here comes our trick { $MatchedArray[] = $i; } } var_dump($MatchedArray); // or echo implode(',', $MatchedArray); Quote Link to comment https://forums.phpfreaks.com/topic/189193-matching/#findComment-998833 Share on other sites More sharing options...
salathe Posted January 20, 2010 Share Posted January 20, 2010 Shouldn't your results also have the range 230-239 or do you wish only those that end in the inputted number? Quote Link to comment https://forums.phpfreaks.com/topic/189193-matching/#findComment-998841 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.