I'm reading a file that has this text:
Vélez Sarsfield|Zárate, Mauro|8|0|0|1|9
Estudiantes|Carrillo, Guido|5|1|0|2|8
Boca Juniors|Gigliotti, Emanuel|3|2|0|2|7
River Plate|Carbonero, Carlos Mario|4|2|0|0|6
Arsenal|Echeverría, Mariano|6|0|0|0|6
Olimpo|Valencia, José Adolfo|6|0|0|0|6
River Plate|Cavenaghi, Fernando Ezequiel|4|0|0|2|6
Boca Juniors|Riquelme, Juan Román|1|0|1|3|5
This is my code:
<?php
$handle = fopen("tp7-datos-goleadores.txt", "r");
if ($handle) {
while (($line = fgets($handle)) !== false) {
// process the line read.
//hago el asociativo
$porciones = explode("|", $line );
$arrAsociativo[$porciones[0]] = $porciones[6];
}
fclose($handle);
} else {
echo "error al leer el archivo";
}
foreach($arrAsociativo as $x => $x_value) {
echo "Key=" . $x . ", Value=" . $x_value;
echo "<br>";
}
?>
But it returns this on the html:
Key=V�lez Sarsfield, Value=9
Key=Estudiantes, Value=8
Key=Boca Juniors, Value=5
Key=River Plate, Value=6
Key=Arsenal, Value=6
Key=Olimpo, Value=6
As you can see, i have 2 Boca Juniors and 2 River Plate on my original text, but i only get one from each when i go through the array. Why is that?