Match numbers

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.

Why check? If the user always digits two numbers, all you have to do is add that number to 100, 200,… , 900.
And maybe multiply it by 10 and then add 1, 2, 3, … ,9 to it.

Off Topic:

You ask a lot of these type of questions. I’m curious, what are you building?

Do you mean the user adds 2 digits 2 and 3 and the script must then check all numbers …

a) ending with x23 ? (123 etc )
b) starting with 23x (231 etc )
c) containing 2x3 ( 203 etc )

Is it for some kind of autocomplete?

What he said. :eye:

You can take your sentence and turn it into code, pretty literally, with something along these lines:


$myNumber = 23; // user key in 2 numbers
for ($i =0; $i <= 999; $i++) { // All numbers  in the range of (0,999)
  if (strrpos($i, $myNumber) !== false) { // script will check to display only numbers with 23
    echo $i . ','; // display only numbers with 23
  }
}