inutero Posted May 6, 2008 Share Posted May 6, 2008 I'm using a simple script to output screencaptures from a video file. My problem is the outputted file name. I'm currently using: $destination="thumb_{$file}.jpg"; Though this outputs thumb_videoname.asf.jpg How would I remove the '.asf' part. Note: I still need to use the current $file variable with extension attached. My idea is to use a new variable to strip it out but am unsure of the correct way to do it: $filestripped={$file} (Strip code here) $destination="thumb_{$filestripped}.jpg" Link to comment https://forums.phpfreaks.com/topic/104340-solved-removing-part-of-a-file-name/ Share on other sites More sharing options...
Perad Posted May 6, 2008 Share Posted May 6, 2008 http://uk.php.net/str_replace - Can be used to strip out the .something $extensions = array(".something", ".somethingelse"); $unextended = str_replace($extensions , "", $file); // hello.something becomes hello Alternatively http://uk.php.net/explode - Can explode the strong around the . $parts = explode('.', $file); // hello.something $unextended = $parts[0]; // parts[0] = hello; parts[1] = something Link to comment https://forums.phpfreaks.com/topic/104340-solved-removing-part-of-a-file-name/#findComment-534189 Share on other sites More sharing options...
inutero Posted May 6, 2008 Author Share Posted May 6, 2008 Thanks so much. Works perfectly! Link to comment https://forums.phpfreaks.com/topic/104340-solved-removing-part-of-a-file-name/#findComment-534192 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.