solved it!!!
function countVotes($haystack, $countAnswers, $needles, $countFunction)
{
//$haystack is the array where we store all the posible answers (array keys must begin from 0)
//$countAnswers is the variable were we store the total amount of votes
//$needles is the array with only 1 vote (but it can contain multiple answers (beware that the answers must correspond with the $haystack))
//$countFunction is the amount of times the function has been called, so the if statement knows when to unset the session variable
$p = 0; // count for while loop
while($p < count($needles))
{//loop while there are new needles
if(is_array($needles))
{//if the needle is an array
if(in_array($needles[$p], $haystack))
{//check if the needle is in the array
$_SESSION['count'][$needles[$p]]++;
}
}
else
{//if the needle is not an array
if(in_array($needles, $haystack))
{//check if the needle is in the array
$_SESSION['count'][$needles]++;
}
}
$p++;
}
if($countFunction == ($countAnswers-1))
{//if there is no new needle anymore, copy the session data to a safe variable which we will return and delete the session data
$count = $_SESSION['count'];
unset($_SESSION['count']);
}
return $count;//return the array with the counted votes
}function countVotes($haystack, $countAnswers, $needles, $countFunction)
{
$p = 0; // count for while loop
while($p < count($needles))
{//loop while there are new needles
if(is_array($needles))
{//if the needle is an array
if(in_array($needles[$p], $haystack))
{//check if the needle is in the array
$_SESSION['count'][$needles[$p]]++;
}
}
else
{//if the needle is not an array
if(in_array($needles, $haystack))
{//check if the needle is in the array
$_SESSION['count'][$needles]++;
}
}
$p++;
}
if($countFunction == ($countAnswers-1))
{//if there is no new needle anymore, copy the session data to a safe variable which we will return and delete the session data
$count = $_SESSION['count'];
unset($_SESSION['count']);
}
return $count;//return the array with the counted votes
}
sorry guys for solving the problem myself...
thanks anyways