remove character in a string

Discussion in 'PHP' started by chxxangie, Oct 27, 2008.

  1. #1
    P7050006-rotate_180.jpg

    - [P7050006] is image filename. will be different.
    - [-rotate_180] is fix character.
    there is 4 possible for the this. there are:-
    P7050006-rotate_90.jpg
    P7050006-rotate_180.jpg
    P7050006-rotate_270.jpg
    P7050006-rotate_360.jpg
    - [.jpg] is the file format. will be diffferent.

    example:
    i want to remove [-rotate_180]. result will be something like P7050006.jpg
     
    chxxangie, Oct 27, 2008 IP
  2. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #2
    $filename = preg_replace('/\-rotate\_\d+/','',$filename);
    PHP:
     
    JAY6390, Oct 27, 2008 IP