You can try iterating over the elements first, and then if you find the original comment, skip it first and then add a flag that will start concatenating the following elements. If you reach the endpoint, stop the concatenation:
$html_string = ' <p>Hello world etc</p> <div>something</div> <div>something2</div> <div>something3</div> '; $html = str_get_html($html_string); // start point $start = $html->find('*'); $output = ''; $go = false; foreach($start as $e) { if($e->innertext === '') { $go = true; continue; } elseif($e->innertext === '') { break; } if($go) { $output .= $e; } } echo $output;
Ghost source share