SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2006
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    can php shoot blanks?

    someone around here helped me recently with a script, I need to make a small adjustent though, if such request is simple enough to incorporate into my existing piece

    The script below lists some files in a folder as links (excluding some specific ones). May it also recognize when an underscore is being used anywhere in the name of any of these files and swap it for a space when it actually displayes the file as link?

    PHP Code:
    <?php
    if ($handle opendir('projects')) {
    while (
    false !== ($file readdir($handle))) {
    if (
    $file != "." && $file != ".." && $file != "_fwds" && !(is_dir($file))) {
    echo 
    "<span class='bodyTextLG'><a href='projects/$file'>" substr($file,0,strpos($file,'.')) . "</a></span><br />"
    }
    }
    closedir($handle);
    }
    ?>

  2. #2
    Dinah-Moe Humm mudshark's Avatar
    Join Date
    Dec 2003
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    str_replace("_"" "substr($file,0,strpos($file,'.'))) 

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    wow, interesting title haha . But yes, as provided above, just use str_replace to replace the underscore with a space, on the "filename" or string.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •