Parse files in a directory and output list (example: tinymce emoticons/emotions)


/ Published in: PHP
Save to your folder(s)

run this from plugins/emotions and copy/paste the output to emotions.htm


Copy this code and paste it in your HTML
  1. <?php
  2. $handle=opendir("img");
  3.  
  4. $i = 0;
  5. while (($file = readdir($handle))!==false) {
  6.  
  7. $imagesizes = getimagesize('img/'.$file);
  8. $width = $imagesizes[0];
  9. $height = $imagesizes[1];
  10.  
  11. echo " <td><a href=\"javascript:EmotionsDialog.insert('$file','$file-0');\"><img src=\"img/$file\" width=\"$width\" height=\"$height\" border=\"0\" alt=\"{#$file-0}\" title=\"{#$file-0}\" /></a></td>"."\n";
  12. if( $i%4 == 0 ) {
  13. echo '</tr>';
  14. }
  15. if( ($i+4)%4 == 0 ) {
  16. echo '<tr>'."\n";
  17. }
  18.  
  19. $i++;
  20. }
  21.  
  22. closedir($handle);
  23. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.