Вы могли отправить HTTP-заголовки, чтобы препятствовать тому, чтобы он кэшировался:
Cache-control: no-cache
Pragma: no-cache
, Как Вы, это зависит от веб-сервера, который Вы используете.
You want the php function "asort":
http://php.net/manual/en/function.asort.php
it sorts the array, maintaining the index associations.
Edit: I've just noticed you're using a standard array (non-associative). if you're not fussed about preserving index associations, use sort():
Обратите внимание, что sort () работает с массивом вместо , поэтому вам нужно только вызвать
sort($a);
doSomething($a);
. Это не сработает;
$a = sort($a);
doSomething($a);
sort()
. This will give a new array with numeric keys starting from 0
.asort()
.See also the comparison table of sorting functions in PHP.