0

i have code

$e = $html->find('span.item_color_title');
echo $e[3]->innertext;

this code good working give element

<span class="item_color_title">
                Minutes Played:
            </span>

but i want number after this element

<div class="item_float_left">
            <div class="section_title">
                ALL TIME STATS
            </div>
            <span class="item_color_title">
                Score:
            </span>
            518
            <br>
            <span class="item_color_title">
                Minutes Played:
            </span>
            305
            <br>
            <span class="item_color_title">
                Score per Minute:
            </span>
            1.7
            <br>
            <span class="item_color_title">
                Rank on Server:
            </span>

i need this 305 numbers after span only please help me

  • Witam Pana próbowałem już w ten sposób ale nie zwraca żadnej wartości ponieważ liczby nie są w elemencie prawdopodobnie – Dobry - team pro Jan 11 '20 at 13:48
  • Please only use english. Not all users speak your native language. You can't go down to the actual element. You're going to need to be up one level, find the element, then take the next value. Something like https://stackoverflow.com/questions/41697522/php-domdocument-get-text-after-tag might help you. – user3783243 Jan 11 '20 at 13:49
  • Yes, please use English here. Ok, try `preg_match('/\s*Minutes Played:\s*<\/span>\s*\K\d+/', $text, $match)`, then `echo $match[0]`. – Ryszard Czech Jan 11 '20 at 13:52
  • this good working thanks Ryszard udanej soboty – Dobry - team pro Jan 11 '20 at 13:56

1 Answers1

0

i think this is what you are looking for:

$page = "YOUR_HTML";

preg_match_all("/<span
class=\"item_color_title\">(\n*|.)*<\/span>(\n|\s|\d.\d)*/", $page,
$matches);

echo($matches[0][1]);