On 10 August 2004 15:36, Labunski wrote:
> Hello,
> First of all, I should apologize for my bad English,
> and I hope somebody will understand what I was trying to say..
>
>
> <?php
> if ($handle = opendir('news')) {
> while (false !== ($topic = readdir($handle))) {
> if ($topic != "." && $topic != "..") {
>
> $topic_b = array($topic); // the problem starts here.
> rsort($topic_b); //array_reverse($topic_b);
>
> foreach($topic_b as $topic_c){
> $date = $topic_c;
> }
> print($date);
>
> }
> }
> closedir($handle);
> }
> >
>
> This way, this will print:
> 2004.08.11
> 2004.08.31
> 2004.11.07
>
> But I want to reverse this array, so that it would print: 2004.11.07
> 2004.08.31
> 2004.08.11
>
> BTW, I thought that $topic is an array
Why? You've done nothing to make it an array -- the only thing you ever assign to it
is a single (string) filename.
Try this (untested!):
<?php
if ($handle = opendir('news')) {
while (false !== ($topic = readdir($handle))) {
if ($topic != "." && $topic != "..") {
$topic_a[] = $topic;
}
}
if (rsort($topic_a, SORT_STRING) {
foreach($topic_a as $topic_c){
print($topic_c);
}
}
closedir($handle);
}
?>
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php