Results 1 to 3 of 3

Thread: Average of values in a string? [Resolved]

Threaded View

  1. #1

    Thread Starter
    Fanatic Member TDQWERTY's Avatar
    Join Date
    Oct 2003
    Location
    Oporto & Leiria, Portugal / Luanda, Angola
    Posts
    972

    Resolved Average of values in a string? [Resolved]

    Hello all,
    I came across a problem with calc an average, the thing is, i have a big string, full of values separated using ; and ,
    Let me show:

    $myString="1,2;2,2;1,3;2,3;2,4";

    The average of that should return something like:

    (1+2+1+2+2)/5
    and
    (2+2+3+3+4)/5

    That string has 2 answers for 1 question, that would do 2 averages, not just one in this case.
    Answer 1 would be 1,6
    Answer 2 would be 2,8

    The answers schema is: <answer1>,<answer2>;<answer1>,<answer2>;...
    But it can be <answer1>,<answer2><answer3>;<answer1>,<answer2><answer3>;...
    or
    <answer1>;<answer1>;<answer1>;...

    Does anyone have any idea on how to solve this?
    Last edited by TDQWERTY; May 28th, 2005 at 02:02 AM.
    ::Winamp 5.xx id3v2 & modern skin support::
    ::NetCF DataGrid Programatically Scroll Example::
    Don't forget to rate posts from those who helped you solving your problem, clicking on and rating it.

Posting Permissions

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



Click Here to Expand Forum to Full Width