Re: [PHP] natsort()

2006-10-27 Thread Richard Lynch
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

Re: [PHP] natsort()

2006-10-26 Thread Dave Hamber
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

[PHP] natsort()

2006-10-26 Thread Sandy
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