Hi,
I have a list of words in a file and want to know how often each item appears in this list. So I use
$cont=file($filename);
$list=array_count_values($cont);
Then I want to just get the count of each value. Let's say in the file is
top1
top2
top2
top1
top3
Then the array $list should contain:
$list[top1]=>2
$list[top2]=>2
$list[top3]=>1
Correct? But now, if I want to assign this to another variable, I don't get anything.
$c1=$list[top1];
produces an empty $c1. When I got the array $list printed, it shows a space at the end of each key, like list[top1 ], and I read that file() reads the content with the linebreaks. So I guess this is the problem. But I don't know how to avoid that. Any help would be appreciated!