Code: Select all
$predata = explode(", ", $_POST['data']);
$data = array_count_values($predata);
rsort($data);
echo 'Mode: '.$data[0].'<br>';Moderator: General Moderators
Code: Select all
$predata = explode(", ", $_POST['data']);
$data = array_count_values($predata);
rsort($data);
echo 'Mode: '.$data[0].'<br>';Code: Select all
$predata = explode(", ", $_POST['data']);
$data = array_count_values($predata);
echo 'Mode: '.min(array_keys(($data))).'<br>';Code: Select all
$predata = explode(", ", $_POST['data']);
sort($predata);
$num = count($predata);
$mid = $num / 2;
echo '<b>Median:</b> '.$predata[$mid].'<br>';Code: Select all
$mid = $num/2;
if(($mid % 1) != 0) // Since you're dividing by two, this will only be 0 or .5
{
$first = $mid - .5;
$second = $mid + .5;
}Make up a situation, find the solutions logically, then use whatever variables you have at your expense to replicate those results.superdezign wrote:Try writing down all of the values you have, then write down all of the values that you want, and then use logic to go from what you have to what you want.