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, Link to comment https://forums.phpfreaks.com/topic/278281-basic-string-containing-script-for-numbers/ 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 Link to comment https://forums.phpfreaks.com/topic/278281-basic-string-containing-script-for-numbers/#findComment-1431609 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. Link to comment https://forums.phpfreaks.com/topic/278281-basic-string-containing-script-for-numbers/#findComment-1431626 Share on other sites More sharing options...
TOA Posted May 22, 2013 Share Posted May 22, 2013 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. Link to comment https://forums.phpfreaks.com/topic/278281-basic-string-containing-script-for-numbers/#findComment-1431634 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.