note 96560 deleted from function.scandir by danbrown

From: Date: Fri, 05 Mar 2010 15:22:28 +0000
Subject: note 96560 deleted from function.scandir by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-166701@lists.php.net to get a copy of this message
Note Submitter: michael dot m dot tadros at gmail dot com ---- Here is a simple script that would go into a certain folder and create links for all the "pdf" files in that folder and display them in a 3 by x table format. <table> <tr> <?php //this is a function that reads the folder contents and displays links for the pdf files in it in a 3 by x table format --m.t. $dir = './'; $files = scandir($dir); $i=1; foreach ($files as $value){ //read file extension $ext = substr($value, strrpos($value, '.') + 1); if (!strcmp($ext,"pdf")){// check the file extension ".pdf" if ($i == 4){//close the current row and start a new one after each 3 columns (change if you want more columns echo "</tr><tr>"; $i = 1;}; ?> <td align="left"><a href="<?php echo $value; ?>"><?php echo $value; ?></a></td> <?php $i++; } } ?> </tr> </table>

« previous php.notes (#166701) next »