djtozz Posted October 9, 2009 Share Posted October 9, 2009 Hello, Following code retrieves the file extension from a url $words=preg_split("/[_\.\-]/",$words); $lastword=array_pop($words); if($lastword=="html") array_pop($words); $words=implode(" ",$words); $words=preg_replace("/\s{2,}/"," ",$words); $caption=mysql_real_escape_string($words); unset($words); The IF statement removes the ".html" extension from the url. I would like to do the same for ".htm" extensions. I'm not sure which pattern to use. Link to comment https://forums.phpfreaks.com/topic/177099-preg_replace-help/ Share on other sites More sharing options...
Bricktop Posted October 9, 2009 Share Posted October 9, 2009 Hi djtozz, Could you not use the OR operator? i.e. if($lastword=="html" || $lastword=="htm") array_pop($words); Hope this helps. Link to comment https://forums.phpfreaks.com/topic/177099-preg_replace-help/#findComment-933758 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.