I use PHP Simple Html Dom to get some html,now i have a html dom like follow code,i need fetch the plain text inner div,but avoiding the p tags and their content(only return 111111), who can help me?Thanks in advance!
<div>
<p>00000000</p>
111111
<p>22222222</p>
</div>
If you text is always at the same position , try this:
It depends on what you mean by "avoiding the p tags".
If you just want to remove the tags, then just running
strip_tags()
on it should work for what you want.If you actually want to just return "11111" (ie. strip the tags and their contents) then this isn't a viable solution. For that, something like this may work:
Here is my solution
I want to get the Primary Text part only.
Edited: If you have PHP errors Try to enclose with If else or try my lazy code
Official Documentation