Page 1 of 1

How to print only numbers in txtbox?

Posted: Thu Dec 13, 2007 10:52 pm
by aditya
Hi

i have one text box . in That text box i would like to print only numbers but not Alphabets . Please send the code in PHP . Urgent Help me please

Posted: Thu Dec 13, 2007 10:55 pm
by John Cartwright
Please stop telling us your problems are urgent. Everyone's post is equally important here, and telling us yours is urgent will likely shy people away from helping you. Furthermore, we arn't here to give you solutions to your problems, this is a place of learning.

A simple preg_match() can capture all the numeric characters in a string using the \d (digit) character.

Thats as much help as you'll get from me until you can show that your at least trying.

Posted: Thu Dec 13, 2007 10:56 pm
by Benjamin

Code: Select all

$x = range(0,9); $i = str_split($q); $m = null; foreach ($i as $t => $o) if (in_array($o, $x)) $m .= $o;