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. 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); 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? Link to comment https://forums.phpfreaks.com/topic/189193-matching/#findComment-998841 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.