Jump to content

Preg_replace Help


djtozz

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.