On Thu, October 26, 2006 4:05 pm, Sandy wrote:
>
> $d = '/somedir/subdir';
> $od = opendir($d);
> if ($od) {
> $dl = scandir($d);
> natsort($dl);
> }
>
>
> The sorted array is available through print_r().
> How can I obtain a natsorted array that can be listed using :
>
> while ($i <= $ar
natsort() places the array elements in natural order but not the keys.
If you want your elements printed using "print" in a loop either
reorganise the keys first or use "foreach".
The easiest method would be to use:
foreach($dl as $filename){
print $filename;
}
If you insist on using
Hi
php5
$d = '/somedir/subdir';
$od = opendir($d);
if ($od) {
$dl = scandir($d);
natsort($dl);
}
The sorted array is available through print_r().
How can I obtain a natsorted array that can be listed using :
while ($i <= $array_count){print $dl[$i]}
Thanks
--
PHP General Mailing
3 matches
Mail list logo