İşte benim düz dosya veritabanı içeriği:
Jacob | Little | 22 | Male | Web Developer *
Adam | Johnson | 45 | Male | President *
İşte benim php kodu:
<?php
$fopen = fopen('db.txt', 'r');
if (!$fopen) { echo 'File not found'; }
$fread = fread($fopen, filesize('db.txt'));
$records = explode('|', $fread);
?>
<table border="1" width="100%">
<tr>
<thead>
<th>First Name</th>
<th>Last Name</th>
<th>Age</th>
<th>Sex</th>
<th>Occupation</th>
</thead>
</tr>
<?php
$rows = explode('*', $fread);
for($i = 0; $i < count($rows) - 1; $i++)
{
echo '<tr>';
echo '<td>'.$records[0].'</td>';
echo '<td>'.$records[1].'</td>';
echo '<td>'.$records[2].'</td>';
echo '<td>'.$records[3].'</td>';
echo '<td>'.$records[4].'</td>';
echo '</tr>';
}
fclose($fopen);
?>
</table>
Sorun yerine 2 kayıtları Yakup için bir ve Adem için bir iki kez tekrarlanan ilk kaydın çıktısını alıyorum olduğunu. Bunu düzeltmek için?