franzwarning Posted June 23, 2011 Share Posted June 23, 2011 Hi, I'm trying to see if the url that I've created ends in .jpg. How would I go about doing that? Cheers, George Quote Link to comment https://forums.phpfreaks.com/topic/240257-determine-last-three-characters-of-a-string/ Share on other sites More sharing options...
Alex Posted June 23, 2011 Share Posted June 23, 2011 ".jpg" is 4 characters. Nevertheless, you can achieve this using substr (check the manual). if(substr($str, -4) == ".jpg")) { // ... } Quote Link to comment https://forums.phpfreaks.com/topic/240257-determine-last-three-characters-of-a-string/#findComment-1234077 Share on other sites More sharing options...
franzwarning Posted June 23, 2011 Author Share Posted June 23, 2011 awesome, thank you! Quote Link to comment https://forums.phpfreaks.com/topic/240257-determine-last-three-characters-of-a-string/#findComment-1234080 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.