Re: Beginner question : Removing spaces in forms
| From: | liljim | Date: | Fri, 13 Dec 2002 11:49:27 +0000 |
| Subject: | Re: Beginner question : Removing spaces in forms | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-128150@lists.php.net to get a copy of this message | ||
Hi Andrew,
"Andrew Wilson" <will@netwaynetworks.com.au> wrote in message:
>
> Hay guys i was wondering if there was a form parameter of something
> equivalent for input text boxes that when a user enters a number or series
> of numbers that it removes the spaces.
> If there is no alternative how would you go about solving this issue.
Am I right in thinking that you want the form input variable to contain
numbers only? If so, you could simply do this:
$variable = preg_replace("![^0-9]!s", "", $variable);
Which would strip out everything that's not numbers.
OR, are you expecting strings like:
"Here's a number you can call for tech support: 12345 6789 - be patient,
they take *forever* to answer!"
If so, you could probably craft some regular expression up to remove the
spaces.
James