I have file
animals.txt
fishes shark,tuna,salmon
birds parrot,pigeon
mammals cow,dog,cat
In every line, for example between fishes and shark is tabulation.
I wanna get this output:
<ul type="disc">
<li>fishes<br>
<ul type="disc">
<li>shark</li>
<li>tuna</li>
<li>salmon</li>
</ul>
</li>
<li>birds<br>
<ul type="disc">
<li>parrot</li>
<li>pigeon</li>
</ul>
</li>
<li>mammals<br>
<ul type="disc">
<li>cow</li>
<li>dog</li>
<li>cat</li>
</ul>
</li>
</ul>
I wrote simple code, but I don't know what can I do next, can someone help me solve it?
index.php
$file = fopen('animals.txt', 'r');
while (!feof($file)) {
$line = fgets($file);
$a = explode(" ", $line);
$b = str_replace(",", " ", $a);
$c = explode(" ", $b);
print_r($b);
}
fclose($file);
?>