add code to array output

hi all.
Is it possible to add some extra default text to the output of an array that list the contents of a directory. I want to add " class=“bump” "to each a_href from the resulting output.
The idea is to add the bumpbox javascript so users can view the files online by clicking the link-
Any ideas how to do this, or a better alternative are very appreciated-

My code is
[php]<?php
// opens this directory
$myDirectory = opendir(“uploads/”);

     // gets each entry
     while($entryName = readdir($myDirectory)) {
       $dirArray[] = $entryName;
     }

     // finds extention of file
     function findexts ($filename)
     {
       $filename = strtolower($filename) ;
       $exts = split("[/\\.]", $filename) ;
       $n = count($exts)-1;
       $exts = $exts[$n];
       return $exts;
     }

     // closes directory
     closedir($myDirectory);

     //  counts elements in array
     $indexCount   = count($dirArray);

     // sorts files
     sort($dirArray);

     // print 'em
     print("<h1>Directory Contents</h1>");
     print("<table width='100%' cellspacing='10'>
             <tr>
               <td class='head'>Filename</td>
               <td class='head'>Type</td></tr>\n");

     // loops through the array of files and print them all
     for($index=0; $index < $indexCount; $index++) {
           if (substr("$dirArray[$index]", 0, 1) != "."){ // don't list hidden files
           print("<tr><td><a href='$dirArray[$index]'>$dirArray[$index]</a></td>");
           print("<td>");
           print(findexts($dirArray[$index]));
           print("</td>");
           print("</tr>\n");
       }
     }
     print("</table>\n");
   ?>[/php]

Can you not just type it into what you’re printing?

[php]print("

$dirArray[$index]");[/php]

becomes:
[php]print("

<a class=“bump” href=’$dirArray[$index]’>$dirArray[$index]");[/php]

Excellent - thanks a lot.
I tried all sorts, but didn’t realise I needed the slashes /
Cheers

Sponsor our Newsletter | Privacy Policy | Terms of Service