I would like to branch using an if statement if a string is a valid digit of length $length. Here is my line of code:
if(!ereg("[[:digit:]]{$length}$", $value, $matches)) {
That code is not returning the correct response, and I think it's because of my use of $length as the pattern length in the regular expression. What is the correct way to use a variable within a regular expression, as in this case?