You are here: Re: multiplication math not working ? « PHP Programming Language « IT news, forums, messages
Re: multiplication math not working ?

Posted by One on 02/07/07 16:49

On Feb 7, 11:34 am, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> $number_percent is a string containing 25, not the numeric value 25.
> When you use a string in a calculation it's numeric value is zero.
>
> Try
> $number_percent=25;
>
> instead (and ensure that $history['order_total'] is also numeric).

Hi Jerry - thanks much for trying.
Same result :
Input :
$number_percent=25;
echo "history['order_total'] is ".$history['order_total']."<br />";
$removeit=str_replace('$' ,'', $history['order_total']);
echo "strip the $ sign ".$removeit."<br />";
$total = ($removeit * $number_percent);
echo "<br />total is ".$total."<br />";

Output :
history['order_total'] is $241.47
strip the $ sign 241.47
total is 0

This is bonkers - I'm *sure* I have done this type of thing in the
past without issue. :-(

 

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

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация