I'm trying to insert THE PHP CODE
between the <div id="con开发者_运维技巧tainer">
THE PHP CODE HERE </div>
. I'm using the http://simplehtmldom.sourceforge.net/ in this Php Html Parser.
I've got this so far, how to find a div having an id called container:
// Find all which attribute id=foo
$ret = $html->find('div[id=foo]');
Then after finding the foo, what's next?
$html->find('div[id=foo]')->innertext = 'bar';
Should do the job but you might be better off modifying the DOM with JS?
Why not modify the source Wordpress template instead of trying to hack in the text later? That PHP snippet could potentially produce a huge chunk of text, and you can't insert it verbatim into the DOM - you can only insert its output (which you'd have to capture with ob_start()/ob_get_clean()
anywyas).
精彩评论