Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Two simple questions 1

Status
Not open for further replies.

krappleby025

Programmer
Joined
Sep 6, 2001
Messages
347
Location
NL
1.

i have a variable that is a number.number i need to display it as a currentcy dollar, however whenever it is a straight figure ie 10.00 it will only display 10 how do i display it as 00.00

2.

how do you end a session in php.

thanks for you help
 
Krappleby025,

I think the folowing will give you the outcome you are looking for.

Code:
<?php
$var = &quot;10.00&quot;;
$cur = &quot;$&quot;; // Currancy

print &quot;$cur$var&quot;;
// the following ? > ends the php script
?>

Regards

Toby Heywood
 
In addition.

<?php
$var = &quot;10.00&quot;;
$cur = &quot;$&quot;; // Currancy

print &quot;$$var&quot;;
// the following ? > ends the php script
?>

The above also works. Out of curiousity where does the variable containing the number.number get it's value? Is the variable set as an Integer? If so try using

settype($var, 'double');

Regards

Toby Heywood
 
Hi,

The var is a number, and you want to display it with 2 decimals... Try this:

Code:
<?
  $value = 10;
  echo &quot;The value is &quot;.number_format($value,2).&quot;\$&quot;;
?>

Terminating a session -I think that die(); does the trick!

Good luck §;O)


Jakob
 
Ending a session is done with
Code:
session_destroy();
.

//Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top