Return to Snippet

Revision: 24843
at March 12, 2010 09:19 by mongolito404


Initial Code
<?php

$results = db_query("SELECT DISTINCT nid from node_revisions WHERE body REGEXP '<style>.*</style>' OR body REGEXP '<style>.*</style>'");

while($nid = db_result($results)) {
  $node = node_load($nid);
  unset($node->teaser);
  $node->body = preg_replace('@<style[^>]*?>.*?</style>@siu', '',$node->body);
  node_save($node);
}
?>

Initial URL


Initial Description
A simple script to run with [drush](http://drupal.org/project/drush) to clean all Drupal nodes containing style tags.

Initial Title
Remove style tags from Drupal node

Initial Tags
php, html, drupal

Initial Language
PHP