Search found 66 matches

by tail
Sat Jun 02, 2007 9:13 pm
Forum: PHP - Code
Topic: put user inputted numbers into ascending order
Replies: 42
Views: 2388

i'm so confused dude :?:
by tail
Sat Jun 02, 2007 5:41 pm
Forum: PHP - Code
Topic: put user inputted numbers into ascending order
Replies: 42
Views: 2388

but i need to echo the results onto the page. so if there were two numbers in the middle, i need to divide those by 2 and then echo that result. but if there is only one in the middle, just echo that result. also, the integer in the middle could be a decimal so it won't always be 0 or .5 ;)
by tail
Fri Jun 01, 2007 9:43 pm
Forum: PHP - Code
Topic: put user inputted numbers into ascending order
Replies: 42
Views: 2388

ok so right now i'm using this to find the middle number: $predata = explode(", ", $_POST['data']); sort($predata); $num = count($predata); $mid = $num / 2; echo '<b>Median:</b> '.$predata[$mid].'<br>'; but if there is an even amount of numbers, i need it to divide the two middle ones. can...
by tail
Fri Jun 01, 2007 5:06 pm
Forum: PHP - Code
Topic: put user inputted numbers into ascending order
Replies: 42
Views: 2388

tail wrote:but what if the inputted numbers were like: 12, 12, 13, 14, 14

is there a way to echo them both? or what if there was no most common number? could you just make it echo the word none?
can you do this? if so, what functions should i look at?
by tail
Fri Jun 01, 2007 4:21 pm
Forum: PHP - Code
Topic: put user inputted numbers into ascending order
Replies: 42
Views: 2388

this worked for me thanks a lot: $predata = explode(", ", $_POST['data']); $data = array_count_values($predata); echo 'Mode: '.min(array_keys(($data))).'<br>'; but what if the inputted numbers were like: 12, 12, 13, 14, 14 is there a way to echo them both? or what if there was no most comm...
by tail
Fri Jun 01, 2007 3:58 pm
Forum: PHP - Code
Topic: put user inputted numbers into ascending order
Replies: 42
Views: 2388

this is what i got so far: $predata = explode(", ", $_POST['data']); $data = array_count_values($predata); rsort($data); echo 'Mode: '.$data[0].'<br>'; but that outputs the number 2. i'm guessing its outputting the number of times the number shows up but not the actual number. is there a w...
by tail
Fri Jun 01, 2007 3:41 pm
Forum: PHP - Code
Topic: put user inputted numbers into ascending order
Replies: 42
Views: 2388

Look at it in the browser's source, not the browser. It should be fairly clear if you used more meaningful values than numbers too. the thing about the numbers is, i'm trying to create a script where it finds the mean(avg of inputted numbers), median(middle of inputted numbers), and mode(most commo...
by tail
Fri Jun 01, 2007 10:59 am
Forum: PHP - Code
Topic: put user inputted numbers into ascending order
Replies: 42
Views: 2388

array(6) { [0]=> string(1) "1" [1]=> string(1) "2" [2]=> string(1) "3" [3]=> string(1) "1" [4]=> string(1) "2" [5]=> string(1) "3" } array(3) { [1]=> int(2) [2]=> int(2) [3]=> int(2) } i don't see how this output helps pick out the most co...
by tail
Thu May 31, 2007 10:50 pm
Forum: PHP - Code
Topic: put user inputted numbers into ascending order
Replies: 42
Views: 2388

i still dont understand what the function is saying that it does. what does it mean when it says their frequency in input as values and input array as keys?
by tail
Thu May 31, 2007 10:21 pm
Forum: PHP - Code
Topic: put user inputted numbers into ascending order
Replies: 42
Views: 2388

i used this but it outputted "Array" instead of the most common integer

Code: Select all

$predata = explode(", ", $_POST['data']);
$data = array_count_values($predata);
echo 'Mode: '.$data.'';
by tail
Thu May 31, 2007 9:41 pm
Forum: PHP - Code
Topic: put user inputted numbers into ascending order
Replies: 42
Views: 2388

i'm confused by this. how would this extract the most common number in the array?
by tail
Thu May 31, 2007 9:33 pm
Forum: PHP - Code
Topic: put user inputted numbers into ascending order
Replies: 42
Views: 2388

is there a way to extract which number appears the most?
by tail
Thu May 31, 2007 8:47 pm
Forum: PHP - Code
Topic: put user inputted numbers into ascending order
Replies: 42
Views: 2388

thanks a lot
by tail
Thu May 31, 2007 8:09 pm
Forum: PHP - Code
Topic: put user inputted numbers into ascending order
Replies: 42
Views: 2388

Thanks! This worked: $data = explode(", ", $_POST['data']); sort($data); foreach ($data as $num) { echo ''.$num.', '; } 3 more questions: 1. is there a way to make the comma not show up on the last result? 2. is there a way to extract just the smallest integer? 3. is there a way to extract...
by tail
Thu May 31, 2007 7:47 pm
Forum: PHP - Code
Topic: put user inputted numbers into ascending order
Replies: 42
Views: 2388

Is there a way to just output the numbers?