Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A little help with my script would we appreciated.
#2
The following links should provide you with a solution to your problem.

http://se2.php.net/manual/en/language.types.integer.php
http://se2.php.net/manual/en/function.round.php

Next to that rounding can also be done in this way (example taken from "Recipes a problem solution approach")

PHP Code:
<?php
//Let's say you live in Canada and want to add GST tax to your amount.
$thenumber 9.99 1.07;
//If you simply outputted this, the value would be skewed.
echo "$" $thenumber "<br />"//Outputs $10.6893
//In order to show the value as a dollar amount, you can do this:
echo "$" sprintf ("%.2f"$thenumber); //Outputs $10.69
?>

Using the function round (taken from:"http://php.about.com/od/learnphp/ss/round_num_PHP.htm").

PHP Code:
echo round(3.141592653);
// Value would be 3.142 
The number "3.14159265" here would refer to the variable you have set. The number behind the "," in this case 3 refers to the amount of digits you wish to display.

Please reply in this topic if this reply did not help you.
Reply


Messages In This Thread
RE: A little help with my script would we appreciated. - by Legion - 10-09-2009, 10:20 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  php form script with upload script help andrewjs18 4 3,349 10-07-2010, 11:46 AM
Last Post: JMK940

Forum Jump:


Users browsing this thread: 2 Guest(s)