i’ve spent a few hours trying to figure this one out, i’ve never used fopen before not sure if it needs to be in loop or not i’ve tried a varity of ways
just trying to get an end result which loads a txt file counts how many times each word has been used and echos the results
<?php $text = fopen("words.txt", "r"); $textarray = explode(" ",$text); foreach($textarray as $numbers) { if(isset($str_count[$numbers])) $str_count[$numbers]++; else $str_count[$numbers]=1; } foreach($str_count as $words => $numbers) echo $words.": ".$numbers.""; ?>