Jump to content

opendar sorting trouble


ricky-spires

Recommended Posts

hello.

 

im having some trouble getting the information i want back from a folder.

 

all i want to get back is the file names in numeric order.

 

i seem to also be getting directories listed.

 

my files are called 1.jpg, 2.jpg, 3.jpg etc up to 50.jpg

 

i have added the work page in the echo. at the moment i get this:

 

 

 

so i want to get rid of the first 2 and put the rest in order .

 

 

this is my code:

<?php
				
if ($pdfImage = opendir('assets/images/pages/')) {
						
while (false !== ($pageImage = readdir($pdfImage))) {
$pageImage = preg_replace('/\D/', '', $pageImage);

echo'<li><a href="'.$pageImage.'">Page '.$pageImage.'</a></li>'; 
}
closedir($pdfImage);
}
?>

it doesnt have to be opendir. if you know another way i would be happy to hear .

 

 

thanks

 

ricky

 

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/277015-opendar-sorting-trouble/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.