In the following code, I need to remove <div class="grid_8"></div>.
They will always be at the start and finish of my string, for example:
<div class="grid_8"><img src="http://rps.sanscode.com/site/assets/media/images/rps_mini_logo.png" border="0" alt="Rapid Print Solutions" style="margin-bottom: 30px;" /> 
<h1></h1> 
</div>
Kaldırmak için preg_replace için uygun bir regex nedir? 8, 1 ile 16 arasında herhangi bir sayı olabilir.
Teşekkürler
Jason
@ Amjad ...
İşte benim kod
public function fix_grid(){
     $result = db::query("select * from sc_content_components where component_value_1 like '%grid_%'")->fetchAll(PDO::FETCH_ASSOC);
     foreach($result as $item){
  $json = json_decode($item['component_value_1']);
  if(is_null($json)) continue;
  $x = reset($json);
  echo htmlspecialchars($x);
  echo "<p>=======================<b>Changes to: </b></p>";
  $patterns = array('/^<(div)((?:\s+\w+(?:\s*=\s*(?:(?:"[^"]*")|(?:\'[^\']*\')|[^>\s]+))?)*)\s*(\/?)>/'
                  , '/<\/(\div+)[^>]*>$/');
  $x = preg_replace($patterns, array('',''), trim($x));
  echo htmlspecialchars($x);
  echo "<hr>";
  $json[0]=$x;
//  $ne['component_value_1'] = json_encode($json);
//  db::where('component_id', $item['component_id']);
//  db::update('sc_content_component', $ne);
     }
 }
Ben (Amjad masad @) aşağıdaki regex kullanarak yaşıyorum ve son div kaldırmaz.
Gördüğünüz gibi ben Döşeme kullanıyorum ve çalışmak için görünmüyor
