rondog Posted November 13, 2009 Share Posted November 13, 2009 I have a bunch of FLV files. Some of them are named weird (automatically) and have more than one "." in their filename. For example, "blahblah.blahsomemore.flv" But then I also have files like "blahblah.flv" Basically I need to get a string that's the same name of the FLV, but with a jpg extension. I either need to find the lastIndexOf('.'); (my flash knowledge) or just find '.flv' and replace it with '.jpg' The thing throwing me off is files with a '.' in the middle of their name Quote Link to comment https://forums.phpfreaks.com/topic/181412-solved-help-with-a-filename-string/ Share on other sites More sharing options...
mikesta707 Posted November 13, 2009 Share Posted November 13, 2009 $string = "blahblah.blahblah.flv"; $tokens = explode(".", $string); array_pop($tokens); $stringNew = implode(".", $tokens); $stringNew .= ".jpg"; echo $stringNew; untested but that should work. edit: fixed a few things, and tested, output: blahblah.blahblah.jpg Quote Link to comment https://forums.phpfreaks.com/topic/181412-solved-help-with-a-filename-string/#findComment-956966 Share on other sites More sharing options...
rondog Posted November 13, 2009 Author Share Posted November 13, 2009 Ahh ok yea it wasn't working at first...This works perfectly, thanks! Quote Link to comment https://forums.phpfreaks.com/topic/181412-solved-help-with-a-filename-string/#findComment-956967 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.