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
https://forums.phpfreaks.com/topic/104340-solved-removing-part-of-a-file-name/
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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.