Re: First stupid post of the year.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tedd wrote:
> Hi gang:
> 
> I have a
> 
> $submit = $_POST['submit'];
> 
> The string contains:
> 
>        A       
> 
> (it's there to make a submit button wider)
> 
> How can I strip out the " " from the $submit string leaving "A"?
> 
> I've tried
> 
>    trim($submit);
> 
> but, that don't work.
> 
> Neither does:
> 
>    $submit = str_replace(' ','',$submit);
> 
> or this:
> 
>    $submit = str_replace(' ';','',$submit);
> 
> I should know what to do, but in this case I don't.
> 
> Help is always appreciated.
> 
> Cheers,
> 
> tedd
> 

The problem is, is that you are not getting

       A       
when you submit your form.

It is being URL encoded by the browser and you are actually getting

 %20 %20 %20 A %20 %20 %20 

So, what you need to do is this

$submit = urldecode($submit);// This will take care of the %20 for spaces
$submit = str_replace(' ','',$submit); // This takes out the encoded entities

That should take care of your problem.

Here is a note from teh html_entity_decode page:

Note: You might wonder why trim(html_entity_decode(' ')); doesn't reduce the string to an empty
string, that's because the ' ' entity is not ASCII code 32 (which is stripped by trim()) but
ASCII code 160 (0xa0) in the default ISO 8859-1 characterset.

/note

So, you might try replacing the   with ASCII 160 char.  I found that if you hold down the alt
key and press 160 on your keyboard, it will create that char for you.  you could also do a chr(160)
and get it in PHP.



-- 
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux