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