Answer the question
In order to leave comments, you need to log in
How to select element if ids are not unique?
Good afternoon!
I'm trying to parse the page, but I've run into a problem where multiple elements have the same id.
Here is the structure I am trying to parse:
<div class="tabs_p">
<div class="tabs_p_d">
<div class="tabs_p_t">Name</div>
<div class="tabs_p_d"></div>
</div>
<div class="tabs_p_v">
5016 </div>
</div>
<div class="tabs_p_d">
<div class="tabs_p_t">ID</div>
<div class="tabs_p_d"></div>
</div>
<div class="tabs_p_v">
506 </div>
</div>
<div class="tabs_p_d">
<div class="tabs_p_t">LS</div>
<div class="tabs_p_d"></div>
</div>
<div class="tabs_p_v">
485 </div>
</div>
<div class="tabs_p_d">
<div class="tabs_p_t">Value</div>
<div class="tabs_p_d"></div>
</div>
<div class="tabs_p_v">
100 </div>
</div>
function Parse($p1, $p2, $p3) {
$num1 = strpos($p1, $p2);
if ($num1 === false) return 0;
$num2 = substr($p1, $num1);
return strip_tags(substr($num2, 0, strpos($num2, $p3)));
}
$string = file_get_contents('$source');
$name = strip_tags(trim(Parse($string, '<h1 item="name">', '</h1>')));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question