sort() warning
| From: | Ashley M. Kirchner | Date: | Wed, 06 Sep 2006 16:47:02 +0000 |
| Subject: | sort() warning | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-241420@lists.php.net to get a copy of this message | ||
Given this piece of code:
$i = 0;
if ($dir = opendir($path)) {
while ($dh = readdir($dir)) {
if ($dh != '.' && $dh != '..') {
$Dirs[$i] = $dh;
$i++;
}
}
}
closedir($dir);
sort($Dirs);
Why does sort() give me the following warning:
PHP Warning: sort() expects parameter 1 to be array, null given in ....
The array contents is as follows ( according to print_r($Dirs) )
Array
(
[0] => 1029
[1] => 1197
[2] => 1254
[3] => 1093
[4] => 1217
[5] => 1272
[6] => 1233
[7] => 1257
[8] => 1017
[9] => 1033
)
The end result I want is that it sorts out that array in ascending order, thus 1017, 1029, 1033, 1042, etc., etc...