1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Rename images with php.

Discussion in 'PHP' started by Jikdor, Jul 7, 2007.

  1. #1
    Im working on a image uploader, what ive done so far is making uppercase to lowe and spaces to underscore... Now i want any char that isent a-z,_ or 0-9 to get deleted. I have serched php.net a bit but cant figure it out. How is it done?

    $file_name=strtolower($file_name);
    $file_name=str_replace(" ","_",$file_name);
    PHP:
     
    Jikdor, Jul 7, 2007 IP
  2. nabil_kadimi

    nabil_kadimi Well-Known Member

    Messages:
    1,065
    Likes Received:
    69
    Best Answers:
    0
    Trophy Points:
    195
    #2
    $file_name=ereg_replace('[^a-z0-9]','',$file_name);
    PHP:
    [a-z0-9]:matches characters from a to z or from 0 to 9,
    [^a-z0-9]:matches characters that aren't from a to z nor from 0 to 9, the ereg_replace function removes this characters, more precisely, it changes them to '' (empty string).
     
    nabil_kadimi, Jul 7, 2007 IP
  3. Jikdor

    Jikdor Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Figured it was best to leave the dots there.. fixed anyway thx.
     
    Jikdor, Jul 7, 2007 IP