I’ve seen many question which are almost what I am looking to do and have led me to almost be able to get it but not quite.
I want to format text as follows within a <p> tag which is within a div.
Page 1 of 2
So in ordinary HTML I used the b tag within the paragraph but can’t seem to figure out how to do that with DomDocument. When I try to create an element like so
$pTag = $dom->createElement("p", "Page <b>1</b> of 2");
It outputs just that without recognising the as HTML. So I thought about it and came up with
$pTag->nodeValue .=
as a way to append a new element but that did no good. It didn’t give me any errors but it didn’t append the <b> tag either. This seems like something that should be simple but doesn’t seem to be.
When I tried echo it outputted the text to the top of the screen, not where I wanted it.
I’d appreciate any advice.
Something like the following should work:
$bTag = $dom->createElement("b", "1"); $pTag = $dom->createElement("p"); $pTag->appendChild($dom->createTextNode("Page ")); $pTag->appendChild($bTag); $pTag->appendChild($dom->createTextNode(" of 2"));