Vollpfosten: ksort

Beitrag lesen

diesmal keine ... :)
ich kriege die fehlermeldung in zeile 35, das bedeutet </table>, wieso, hier nochmal der ganze code:
#!/usr/local/bin/php
<table border="1">
  <thead>
<tr>
<th>Filiale</th><th>Nr.</th><th>PLZ</th><th>Ort</th>
<th>Strasse</th><th>Marktleiter</th><th>Fleischabtltr.</th>
<th>Telefon</th><th>Telefax</th><th>Email</th>
</tr>
  </thead>
  <tbody>
<?php
$row = 1;
$fp = fopen ("filialen.csv","r");
$diff = 20000;
$stack_of_results=array();
while ($data = fgetcsv($fp, 1000, ";")) {
 if (abs($data[2] - $PLZ) < $diff) {
  $key=$diff;
  $stack_of_results[$key][]=$data; # Achtung $diff ist nicht unique, daher hier als ArrayOfArrays speichern }
}
ksort($stack_of_results);
$output = array_slice ($stack_of_results, 0, 5);
$c=0;
foreach($output as $v){
  $c++;
  echo 'Ergebnis '.$c;
 foreach($v as $one){
  echo join(', ',$one).'<hr>';
 }
}

?>
  </tbody>
</table> // hier der fehler

Huhu Vollpfosten

mmh, das kommt mir irgendwie bekannt vor ;-)

Vielleicht funktioniert es in etwa so:

$row = 1;
$fp = fopen ("filialen.csv","r");
$diff = 20000;
$stack_of_results=array();
while ($data = fgetcsv($fp, 1000, ";")) {
if (abs($data[2] - $PLZ) < $diff) {
  $key=$diff;
  $stack_of_results[$key][]=$data; # Achtung $diff ist nicht unique, daher hier als ArrayOfArrays speichern }
}
ksort($stack_of_results);
$output = array_slice ($stack_of_results, 0, 5);
$c=0;
foreach($output as $v){
  $c++;
  echo 'Ergebnis '.$c;
foreach($v as $one){
  echo join(', ',$one).'<hr>';
}
}

Viele Grüße

lulu