1

I'm using PHP Simple HTML DOM Parser for my project..

How i can find element after of current element?

Ex:

<h2 class="block-title">Block A</h2>
<div class"block-content">Block A content ...</div>
<h2 class="block-title">Block B</h2>
<div class"block-content">Block B content ...</div>
<h2 class="block-title">Block C</h2>
<div class"block-content">Block C content ...</div>

Expected results ex

"Block A" => "Block A content ...",
"Block B" => "Block B content ...",
"Block C" => "Block C content ..."

1 Answer 1

1

You need to use next_sibling() to selecting element after selector.

$html->find('h2[class=block-title]')->next_sibling()->innertext()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.