I have the following code:
<div id="coursename">
<h1>My Golf Club<br>
<span class="courseregion">My Region</span></h1>
</div>
What I want to do is get the course name and it's region. Separately. Now, because the region is inside the #coursename
element, I firstly want to get .courseregion
, then remove it so I don't end up with My Golf ClubMy Region
This is what I'm trying but it still returns both together:
$course_region = $html->find('.courseregion', 0);
$region_to_use = $course_region; // stored
$course_region->outertext = ""; // get rid of course region
$course_name = $html->find('#coursename', 0);
echo $course_name->plaintext; // returns -> My Golf ClubMy Region
Where am I going wrong? Any ideas?
UPDATE I cannot modify the html, it is what it is
Just work with the strings, don't try to modify the HTML. In this case: