I am working on my web programming homework, and I am stumped.
1) I read in a file and implode it into a string(using spaces as separators because words ran together without them).
2) I strip the html and php tags with strip_tags.
3) I explode the string using spaces.
4) I sort the list using natcasesort.
5) I echo the list of words (with breaklines after each word).
The output comes with about 100 blank lines before it shows the words. The words are not the problem, but the blank lines are. I looked at the source, and all I see is a lot
<br>
tags with nothing in between them. My assumption was that it was php tags like \n or \t, but removing them before exploding did not help. I now am desperate and am looking for any help anyone can provide. Here is the php code:
<?php
echo "<html><head><title>Assignment 1 - File Indexer</title></head><body>";
$url="C:\cs393\Web\Assignment1\Homework 3 test page.htm";
echo "<br><br>Index of words:<br>";
$special=array("\n","\t","'s","'ed","'re",",",".","!","°","(",")","\"",":");
$words=strip_tags(implode(' ',file($url)));
$words=str_replace($special,"",$words);
$list_of_words=explode(' ',$words);
natcasesort($list_of_words);
$single_words = $list_of_words[0];
foreach($list_of_words as $word)
{
echo strtolower($word)."<br>";
}
echo "</body></html>";
?>