This is my problematic function:
[php]function LikeCounter($names)
{
$likes = 0;
echo($names);
for ($i = 0; $i == $count; $i++)
{
echo(‘Works!’);
if ($names{$i} == ‘,’)
{
$likes += 1;
}
}
return $likes;
}[/php]
This function is used to count the commas in the string in order to determine how many users “liked” the comment.
When I register a new user and go to his profile, there is already a message on the profile page and the message “Works!” is shown along with 0 “likes”.
When I “like” the comment, "username, " is echoed, but not “Works!” and the returned value is still 0
If I keep “liking” the comment, I just end up with “username, username, username, …” echoed and the same problem occurs.
Why is the loop only working the first time I call the function?
Thanks in advance! 