Jump to content

Use Simple HTML DOM Parser to append id of DIV


mjahkoh

Recommended Posts

I'm using the "PHP Simple HTML DOM Parser" - http://simplehtmldom.sourceforge.net/manual.htm

 

I'm running through a bunch of elements and I need to change to change

 

This              <div class="tpsobivc_doted"></div>

 

To this          <div class="tpsobivc_doted"  id="tpsobivc_doted"></div>

 

 

Regards

Jackson

My memory of Simple Html Dom is vague.

 

Try

 

<?php
$html = file_get_html('http://www.somesite.com'); # I assume its from a url not a string, otherwise use str_get_html
$div = $html->find('div[class=tpsobivc_doted]');
$div->id = 'topic_solved';
?>

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.