Results 1 to 3 of 3
  1. #1
    Newbie
    Join Date
    January 18th, 2005
    Posts
    36
    Hello Everyone

    For thoes who are trying to deal with the filenames in php here is a code snippet how to handle the file names.

    this will remove all extra characters and give you nice and clean file name.

    $filename = $row['ProductName'];
    $filename= substr($filename, 0, 30);
    $filename= preg_replace("/[ \/]/", "-",$filename);
    $filename = preg_replace("/[^A-Za-z0-9_]+/", "-", $filename);
    $filename = $filename."-".$row['ProductID'].".php";

    This code deals with datafeeds from linkshare.

    Harry Hovak
    http://www.affiliatesignup.com

  2. #2
    ABW Ambassador CrazyGuy's Avatar
    Join Date
    January 18th, 2005
    Posts
    1,463
    If I'm reading it right (I tend to use Perl but reg exp are similar) the only thing I'd suggest is that you could end up with a filename with multiple sequential hyphens in it, so you might add a line to replace those incidences with single.


    --------------
    Are you Crazy?

  3. #3
    Newbie
    Join Date
    January 18th, 2005
    Posts
    36
    CrazyGuy you are right I didnt notice that till now.

    Thanks

    Harry Hovak
    http://www.affiliatesignup.com

  4. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. File Structure and File Names...
    By tfmurphhk in forum WebMerge (Fourthworld.com)
    Replies: 4
    Last Post: March 2nd, 2005, 12:51 PM
  2. File names in v2.4
    By FourthWorld in forum WebMerge (Fourthworld.com)
    Replies: 6
    Last Post: December 27th, 2003, 02:10 PM
  3. Proposal: file names in v2.3
    By FourthWorld in forum WebMerge (Fourthworld.com)
    Replies: 18
    Last Post: October 14th, 2003, 08:22 PM
  4. File Names
    By John Kruger in forum Search Engine Optimization
    Replies: 3
    Last Post: August 29th, 2003, 09:57 AM
  5. Changing File Names
    By cazzie in forum Search Engine Optimization
    Replies: 8
    Last Post: October 24th, 2002, 01:59 PM

Posting Permissions

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