vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   If there's only one number after the decimal place in a value - add a 0 after it. (https://vborg.vbsupport.ru/showthread.php?t=61254)

Link14716 02-06-2004 08:36 PM

If there's only one number after the decimal place in a value - add a 0 after it.
 
How would I go about pulling something like this off?

g-force2k2 02-06-2004 09:20 PM

try the round function.

PHP Code:

$newnumber round $number) ; 

Cheers,
g-force2k2

Link14716 02-06-2004 09:22 PM

The number is already rounded to two decimal places before being store in the database. I'll try using round again before it is displayed, I don't think it'd work though.

EDIT: No dice.

g-force2k2 02-06-2004 09:25 PM

It could perhaps be the column field type that's causing the problem.

Cheers,
g-force2k2

Link14716 02-06-2004 09:27 PM

Quote:

Originally Posted by g-force2k2
It could perhaps be the column field type that's causing the problem.

Cheers,
g-force2k2

Well, it doesn't work when I try it before displaying the number.

The column type is varchar.

g-force2k2 02-06-2004 09:41 PM

There could perhaps be an easier way then I know of, but instead I just made a quick fucntion:

PHP Code:

function twopl_round $number )
{
    
$numbits explode "."$number ) ;
    if ( 
strlen $numbits[1] ) < ) :
        
$number.= '0' ;
    endif ;
    return 
$number ;


Just call the function by:

PHP Code:

$number twopl_round $number ) ; 

Cheers,
g-force2k2

Link14716 02-06-2004 09:47 PM

Works like a charm! Thanks, g-force!

g-force2k2 02-06-2004 09:49 PM

Quote:

Originally Posted by Link14716
Works like a charm! Thanks, g-force!

Hey no problem, glad it worked :)

Cheers,
g-force2k2

Xenon 02-06-2004 11:30 PM

i know you've got the way you want it already, but i may say, there is already a function in php which does that afaik

PHP Code:

$number number_format($number2'.'''); 


Link14716 02-06-2004 11:41 PM

That shows how much I use number_format :p

Thank you, Xenon and g-force2k2 for the help. :)


All times are GMT. The time now is 07:07 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00989 seconds
  • Memory Usage 1,736KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete