savagenoob Posted May 13, 2010 Share Posted May 13, 2010 I am passing a filepath into a variable like "D:\Example\Next\~3880-0.TMP" and need to strip everything but the file name. For a reason unknown to me, PHP is throwing an error while trying to explode \ like "$File=explode("\",$string);", then I was going to use end() to get to the last part of the array, but its not working. Thanks Link to comment https://forums.phpfreaks.com/topic/201587-explodeparsing-a-filepath-help/ Share on other sites More sharing options...
kenrbnsn Posted May 13, 2010 Share Posted May 13, 2010 Use the basename function. The problem you're having is that the backslash is the escape character in PHP so you would have to do <?php $File=explode("\\",$string); ?> Ken Link to comment https://forums.phpfreaks.com/topic/201587-explodeparsing-a-filepath-help/#findComment-1057546 Share on other sites More sharing options...
savagenoob Posted May 13, 2010 Author Share Posted May 13, 2010 Yeah I knew it was something dumb... Thanks bud. Link to comment https://forums.phpfreaks.com/topic/201587-explodeparsing-a-filepath-help/#findComment-1057549 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.