Announcement

Collapse
No announcement yet.

array_sum() - how to use?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • TimCoston
    replied
    yes, "array_sum()" is what you want...

    if you want all the "$estmiate[]" values to sum up into one variable - then do this:

    $total = array_sum($estimate);

    and if $estimate is this:
    $estimate[0] = 1;
    $estimate[1] = 3;
    $estimate[2] = 12;

    then $total will be "16";

    Tim Too... :-)

    Leave a comment:


  • Tim Mousel
    started a topic array_sum() - how to use?

    array_sum() - how to use?

    Hi,

    I found array_sum() in the manual but I'm having a hard time applying it. Maybe there is a different way I should be approaching this?

    I want to get a total for all the values of $estimate[$t].

    PHP Code:
    for($t=0$t<= ($number 1); $t++) {
    $estimate[$t] = ($width[$t] + $length[$t]);
    $temp $t 1;
    echo 
    "<BR>$estimate[$t] is estimate $temp<BR>";


    Is array_sum() what I would use and how would it be used?

    Thanks,

    Tim
widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
Working...
X