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 Link to comment https://forums.phpfreaks.com/topic/48021-solved-how-to-get-the-last-letters-from-an-array/ 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); Link to comment https://forums.phpfreaks.com/topic/48021-solved-how-to-get-the-last-letters-from-an-array/#findComment-234707 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? Link to comment https://forums.phpfreaks.com/topic/48021-solved-how-to-get-the-last-letters-from-an-array/#findComment-234713 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 Link to comment https://forums.phpfreaks.com/topic/48021-solved-how-to-get-the-last-letters-from-an-array/#findComment-234715 Share on other sites More sharing options...
JJohnsenDK Posted April 21, 2007 Author Share Posted April 21, 2007 aha! allrigth... thanks for helping out Link to comment https://forums.phpfreaks.com/topic/48021-solved-how-to-get-the-last-letters-from-an-array/#findComment-234717 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 :-) Link to comment https://forums.phpfreaks.com/topic/48021-solved-how-to-get-the-last-letters-from-an-array/#findComment-234719 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.