Forum Moderators: coopster

Message Too Old, No Replies

Scripting for filtering number strings in a database

e.g. 12 - 16 - 22 - 29 - 41

         

internetheaven

4:56 pm on Aug 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Anyone know a good tutorial on string filtering for thousands of number string records in a mysql database e.g.

12 - 16 - 22 - 29 - 41
15 - 21 - 31 - 47 - 98
01 - 06 - 43 - 44 - 71
etc.

say I wanted to get rid of all strings that consisted of only even/odd numbers. Or get rid of any string where the first two/three/four numbers are consecutive. Or get rid of any strings that have their first number as 1 and their last number as 99. That sort of filtering.

With all the random number/security code generators on the web I'm kind of hoping that there's several good tutorials but I just can't seem to find them.

Thanks
Mike

siMKin

10:36 pm on Aug 28, 2006 (gmt 0)

10+ Year Member



i don't think you'll find a tutorial that directly tackles your question. it's much too specific for that.
It's just a matter of applying programming skills.

in the example you posted you can use explode() to create an array or all the numbers
$numbers = explode(" - ", $string);
then it's just a matter of looping through that array and determine with some if-else constructions what the appropriate action is

[edited by: siMKin at 10:36 pm (utc) on Aug. 28, 2006]