You are here: Re: $ sign input « PHP Language « IT news, forums, messages
Re: $ sign input

Posted by Sean on 04/20/07 09:09

"Gleep" <Gleep@Gleep.com> wrote in message
news:gdcg23pc56j07od8dti04nv75g1lefqa8p@4ax.com...
> On Thu, 19 Apr 2007 20:42:27 -0400, "Art" <c_art@bellsouth.net> wrote:
>
>>Can anyone help? I've got a text input box where the user occasionally
>>enters $ sign. For example they might enter $90,000 for a dollar amount.
>>The problem i'm having is that my php script is seeing this as a variable.
>>I'm not sure how to get around this problem.
>>
>>Art
>>
>
>
> what I do is filter out the $ , then insert just the number with a
> simple function
>
> function clear_currency($cca){
> $ccb = array("$","," );
> $ccc = str_replace($ccb, "",$cca );
> return $ccc;
> }
>
>
> so you post the form and clean the money var
>
> $money = clear_currency($_POST['moneyVar']);
>
> then you do what you like with the $money variable
>
>
> If you want the form to be 'sticky' to reshow the client the number in
> currency format,
> you do it this way
>
> <input type="text" name="moneyVar" value="<?= "\$".
> number_format($money); ?>" >
>
> that should do it.


"Gleep" <Gleep@Gleep.com> wrote :
> function clear_currency($cca){
> $ccb = array("$","," );
> $ccc = str_replace($ccb, "",$cca );
> return $ccc;
> }


Perhaps, you could use a slight variation on the theme...

function clear_currency($cca)
{
$ccc = $cca;
$ccc = str_replace("\$", "[USD] ",$ccc);
$ccc = str_replace("£", "[GBP] ",$ccc);
return $ccc;
}

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация