10000 to 10,000.00

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

GeOrGe
New php-forum User
New php-forum User
Posts: 6
Joined: Thu Jul 18, 2002 11:56 pm

10000 to 10,000.00

Postby GeOrGe » Thu Jul 25, 2002 4:57 am

Hello everyone.
How can I make a number given from a user to look like price?
The output of the script below is 45.678912.45678.912.4567891226 if the $drx parameter is 12345678.

Code: Select all

$workStr=''.$drx;
$drxoutput=$workStr.substr(0,$workStr);
$dNum=$workStr-0;
if ($dNum>=1000) {
$dLen=count($drxoutput);
$drxoutput=''.($dNum/1000).'.'.$drxoutput.substr($dLen-3,$dLen);
}

if ($dNum>=1000000) {
$dLen=count($drxoutput);
$drxoutput=''.($dNum/1000000).'.'.$drxoutput.substr($dLen-7,$dLen);
}
echo"$drxoutput";

GeOrGe
New php-forum User
New php-forum User
Posts: 6
Joined: Thu Jul 18, 2002 11:56 pm

format_number...

Postby GeOrGe » Thu Jul 25, 2002 5:35 am

Yes I know.
format_number...
Sorry fot the post


Return to “PHP coding => General”

Who is online

Users browsing this forum: Google [Bot] and 1 guest