Jump to content

[SOLVED] Removing part of a file name.


inutero

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.