SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast therat's Avatar
    Join Date
    May 2004
    Location
    London
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Maths function problems.

    I have borrowed the following function from a phpBB MOD and want to use it elsewhere but cant get it working. The function is
    PHP Code:
        function do_math($firstval$value$total)
        {
            
    $cst = ($firstval 0) ? 90 $firstval 90;
            if (
    $value != 0
            {
                
    $percentage = ( $total ) ? roundmin(100, ($value $total) * 100)) : 0;
            }
            else
            {
                
    $percentage 0;
            }
            
    $bar_percent round($value $cst);
        } 
    When I call the function I dont get any output, not even an error message. I have called it using the following, the numbers are chosen at random to see what output I got. I assume it is the actual function that is wrong, any suggestions.
    PHP Code:
    $statistics do_math('188''22''33');
    print_r ($statistics

  2. #2
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    21
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    add this to the end of the function:
    return array ($cst, $percentage, $bar_percent);

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2006
    Location
    UK
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why do you work out the variable $percentage, and then not do anything with it?
    You should return something....

    EDIT: Sorry - started reply when there were no others...

  4. #4
    SitePoint Enthusiast therat's Avatar
    Join Date
    May 2004
    Location
    London
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by exam
    add this to the end of the function:
    return array ($cst, $percentage, $bar_percent);
    Works perfectly, thanks.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •