Vince889 Posted June 2, 2009 Share Posted June 2, 2009 I have a directory full of php.txt files and I want to chop off the .txt part. But I need to do this with PHP. How do you a mass rename with PHP? This is what I have so far: <? $directory = "./"; $phptxtfiles = glob("" . $directory . "*.php.txt"); foreach($phptxtfiles as $phpfiles) { #### } ?> the snippet above pulled out all of the php.txt files, now how do i loop through and chop the ".txt" part off of all of them? and another thing... when i echo my $phptxtfiles variable, it has those two annoying periods at each end. why don't they disappear? Quote Link to comment https://forums.phpfreaks.com/topic/160719-removing-periods-and-renaming/ Share on other sites More sharing options...
.josh Posted June 2, 2009 Share Posted June 2, 2009 $string = "a.php.txt"; $string = substr($string,0,-4); as far as those "annoying periods at each end" can you please elaborate? Quote Link to comment https://forums.phpfreaks.com/topic/160719-removing-periods-and-renaming/#findComment-848203 Share on other sites More sharing options...
Vince889 Posted June 3, 2009 Author Share Posted June 3, 2009 Encapsuled variables. Quote Link to comment https://forums.phpfreaks.com/topic/160719-removing-periods-and-renaming/#findComment-848236 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.