I want to match 6 numbers with a / and another 6 numbers.
123456/123456
If a user enteres anything other than this i want it to return an error, how can I do this?
if(preg_match('#^[0-9]{6}/[0-9]{6}$#', $text)) { // valid } else { // not valid }
thanks, what is the # and the ^ for?
The # is being used as the expression delimiter, and the '' (in the context that it appears) is used to denote the beginning of a line (it's the compliment of '$' which, in the context that it appears, is being used to denote the end of a line).