Skip to content

Instantly share code, notes, and snippets.

@giovanniramos
Last active October 7, 2015 00:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giovanniramos/3078188 to your computer and use it in GitHub Desktop.
Save giovanniramos/3078188 to your computer and use it in GitHub Desktop.
Removes the style markup in html tags, derived from a text editor
<?php
/**
* Removes the style markup in html tags, derived from a text editor
*
* @param string $value The input string
* @return string
* @link https://gist.github.com/3078188
*
* */
function clearStyle($value)
{
$value = preg_replace("~<(a|ol|ul|li|h[1-6r]|d[dlt]|em|p|i|b|s|strong|span|div|table|t[dhr])\s?(style.*)?/>~i", "<$1>", $value);
return $value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment