generate functionThu, 10 Nov 2022

php domdocument find second h2 element and append item before it

function my_function($dom) { $h2s = $dom->getElementsByTagName('h2'); $h2 = $h2s->item(1); $item = $dom->createElement('li', 'item'); $h2->parentNode->insertBefore($item, $h2); }

Questions about programming?Chat with your personal AI assistant