note 96560 added to function.scandir
| From: | michael dot m dot tadros at gmail dot com | Date: | Fri, 05 Mar 2010 03:13:58 +0000 |
| Subject: | note 96560 added to function.scandir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-166691@lists.php.net to get a copy of this message | ||
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>
----
Server IP: 69.147.83.197
Probable Submitter: 129.107.98.66
----
Manual Page -- http://www.php.net/manual/en/function.scandir.php
Edit -- https://master.php.net/note/edit/96560
Del: integrated -- https://master.php.net/note/delete/96560/integrated
Del: useless -- https://master.php.net/note/delete/96560/useless
Del: bad code -- https://master.php.net/note/delete/96560/bad+code
Del: spam -- https://master.php.net/note/delete/96560/spam
Del: non-english -- https://master.php.net/note/delete/96560/non-english
Del: in docs -- https://master.php.net/note/delete/96560/in+docs
Del: other reasons-- https://master.php.net/note/delete/96560
Reject -- https://master.php.net/note/reject/96560
Search -- https://master.php.net/manage/user-notes.php