JJohnsenDK Posted April 21, 2007 Share Posted April 21, 2007 Hey A quick and easy quesstion. Simply cant remember what the function is called. A function that gets the last letters in a word? For exampel this word: picture_of_water.psd Then i want to check if the last four letters are: .psd. Thank you for your time Quote Link to comment Share on other sites More sharing options...
taith Posted April 21, 2007 Share Posted April 21, 2007 <? function get_filetype($filepath){ return strtolower(substr($filepath, strpos($filepath, strrchr($filepath, ".")))); } ?> in which wherever your trying to get the type... just... $type=get_filetype($yourfilepath); Quote Link to comment Share on other sites More sharing options...
JJohnsenDK Posted April 21, 2007 Author Share Posted April 21, 2007 Hey again mate... long time ... I dont understand where the script check the four last letters? Quote Link to comment Share on other sites More sharing options...
taith Posted April 21, 2007 Share Posted April 21, 2007 ahoy! um... sorta... it searches the string for the last "." and cuts off everything before it... so... echo get_filetype('index.php'); // ouputs .php echo get_filetype('missing.html'); // ouputs .html Quote Link to comment Share on other sites More sharing options...
JJohnsenDK Posted April 21, 2007 Author Share Posted April 21, 2007 aha! allrigth... thanks for helping out Quote Link to comment Share on other sites More sharing options...
taith Posted April 21, 2007 Share Posted April 21, 2007 no prob... i have yet to hacker proof that one... just to letcha know :-) Quote Link to comment 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.