I'm very new to php and I am trying to write a small application that reads a text file and makes it into an un-ordered list. My goal is to make the text file more readable, so I want to make the headers bold, and simply make the listed items have little markers by them (like they should if they are in an un-ordered list). I wrote the php to do this, but it is not doing what I expected. Instead, it takes each line and makes it bigger and bigger font until it gets so big its unreadable. I cannot see what I am doing wrong here. Does anyone see something that I am missing or have written incorrectly? Below I have pasted the original text file and my php code respectively. Thanks in advance for your help and patience with my limited php knowledge.
Best Picture
American Hustle
Captain Phillips
Dallas Buyers Club
Gravity
Her
Nebraska
Philomena
12 Years a Slave
The Wolf of Wall Street
Best Actor
Christian Bale (American Hustle)
Bruce Dern (Nebraska)
Leonardo DiCaprio (The Wolf of Wall Street)
Chiwetel Ejiofor (12 Years a Slave)
Matthew McConaughey (Dallas Buyers Club)
Best Actress
Amy Adams (American Hustle)
Cate Blanchett (Blue Jasmine)
Sandra Bullock (Gravity)
Judi Dench (Philomena)
Meryl Streep (August: Osage County)
** The 3 headers are supposed to be best picture, best actor, and best actress.
** Below is my php code so far:
<html>
<head>
<title>Un-ordered List</title>
</head>
<body>
<?php
$file = fopen("oscars.txt", "r");
$i=0;
while(!feof($file))
{
$members[]= fgets($file);
}
fclose($file);
$arrlength =count($members);
$title = True;
echo $members;
for($i=0;$i<($arrlength);$i++)
{
if($title=True)
{
echo "<h2>" . $members[$i] . "<h2><ul>";
$title = False;
}
if(trim($members[$i])=='')
{
echo "</ul><h2>" . $members[$i+1] . "</h2><ul>";
$i++;
}
else
{
echo "<li>" . $members[$i] . "</li>" ;
}
}
?>
</body>
</html>