Mastershrimp: Lösung gefunden!

Beitrag lesen

Habs herausgefunden! SelfPHP hat Mist erzählt. Die Funktion sortiert zwar einen Array, lässt aber die Nummerierung bestehen, sodass man bei for() immer noch die alte Reihenfolge ausgibt.

In den Comments stand dann folgender Hinweis, der das Problem löste:

Something that should probably be documented is the fact that both natsort and natcasesort maintain the key-value associations of the array. If you natsort a numerically indexed array, a for loop will not produce the sorted order; a foreach loop, however, will produce the sorted order, but the indices won't be in numeric order. If you want natsort and natcasesort to break the key-value associations, just use array_values on the sorted array, like so:

natcasesort($arr);
$arr = array_values($arr);

Danke an alle, die sich die Mühe gemacht haben, mir zu helfen!