tuoinside Posted May 22, 2013 Share Posted May 22, 2013 Hello all! I am looking for a quick script that will examine a string of numbers, and output consecutive numbers that are not present in a given range. IE. string = 1, 3, 4, 5, 9, 10, 12 Returns = 2, 6, 7, 8, 11, 14 for range 1-14 etc. Could this be done with a match or strpos function? Any help would be greatly appreciated!!! Thanks in advance, Quote Link to comment Share on other sites More sharing options...
Eiseth Posted May 22, 2013 Share Posted May 22, 2013 is this a homework? // create an array of range (1-14) // turn your present numbers into an array // loop each number in the range // check if the current number is not in the array // echo it or save whatever Quote Link to comment Share on other sites More sharing options...
Q695 Posted May 22, 2013 Share Posted May 22, 2013 is this a homework? // create an array of range (1-14) // turn your present numbers into an array // loop each number in the range // check if the current number is not in the array // echo it or save whatever I don't do homework. Quote Link to comment Share on other sites More sharing options...
TOA Posted May 22, 2013 Share Posted May 22, 2013 (edited) If I understand you correctly, try this: array_diff I don't do homework. That doesn't mean others won't help if he makes an attempt. Edited May 22, 2013 by TOA Quote Link to comment 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.