author: Krasimir Tsonev

Hi there, I'm . Senior front-end engineer with over 13 years of experience. I write, speak and occasionally code stuff. Follow me on Twitter, GitHub, Facebook or LinkedIn

Remove html tags from a string wtih PHP

Sometimes you don't need any formatting. That's just a nice way to remove all the html tags.
Remove all tags:

	function removeTags($str) {  
		$str = preg_replace("#<(.*)/(.*)>#iUs", "", $str);
		return $str;
Remove a specific tag:

	function removeTag($str, $tag) { 
		$str = preg_replace("#\\<".$tag."(.*)/".$tag.">#iUs", "", $str);
		return $str;
If you enjoy this post, share it on Twitter, Facebook or LinkedIn. Or maybe comment below: