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 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")) { // ... } 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! 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
Archived
This topic is now archived and is closed to further replies.