[PHP] Check For Space

2003-04-02 Thread shaun
Hi,

How can i make sure a value sent from a form has no spaces in it?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Check For Space

2003-04-02 Thread Chris Hayes
At 17:16 2-4-03, you wrote:
Hi,

How can i make sure a value sent from a form has no spaces in it?
Before sending: javascript that prevents this on sending or even while 
typing.  Check the javascript form faqs on www.irt.org for this.

After sending:

Detect spaces with
if (!(strpos(' ', $string)===false) {ECHO bloody idiot, i told you not to 
do that. Stupid User!;}

In PHP you can remove spaces at start and end of the entry with trim(...).

Remove all spaces in a string with $string=str_replace(...) (replace   
with ).

 (see manual www.php.net/manual  for proper use of these functions.) 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Check For Space

2003-04-02 Thread Marek Kilimajer
if(strpos($string, ' ') === false) {
   //space found
}
if you don't want any white character:
if(ereg('\s',$string)) {
   //white character found
}
shaun wrote:

Hi,

How can i make sure a value sent from a form has no spaces in it?



 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php