3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php if (PHP_VERSION !== '7.2.7') { exit; } $data = <<< HTML <html><body> <div class="membersListRow"> <span class="hoverstateBorder"></span> <span class="avatar"><img src="http://services.runescape.com/m=avatar-rs/x%A0Appolyon%A0x/chat.png?cachebust=1529804535501" alt="x Appolyon x" title="" /></span> <span class="name">x Appolyon x</span> <span class="clanRank">Deputy Owner</span> <span class="proStatus"></span> <span class="totalXP">31,330,901</span> <span class="kills">0</span> <span class="onlineStatus"> <span class="imageIcon"> <img alt="online" src="http://www.runescape.com/img/global/myprofile/icon-status-green.png"> </span> <span class="world"> RS 72 </span> </span> <span class="hoverstate"></span> <form action="http://services.runescape.com/m=hiscore/compare.ws" method="post" class="viewStats"> <input type="hidden" name="user1" value="x%A0Appolyon%A0x" /> <input class="gotoStats" type="submit" value="" /> </form> </div> <div class="membersListRow"> <span class="hoverstateBorder"></span> <span class="avatar"><img src="http://services.runescape.com/m=avatar-rs/Ashmund/chat.png?cachebust=1529804535501" alt="Ashmund" title="" /></span> <span class="name">Ashmund</span> <span class="clanRank">Deputy Owner</span> <span class="proStatus"></span> <span class="totalXP">42,403,390</span> <span class="kills">1</span> <span class="onlineStatus"> <span class="imageIcon"> <img alt="online" src="http://www.runescape.com/img/global/myprofile/icon-status-red.png"> </span> <span class="world"> Offline </span> </span> <span class="hoverstate"></span> <form action="http://services.runescape.com/m=hiscore/compare.ws" method="post" class="viewStats"> <input type="hidden" name="user1" value="Ashmund" /> <input class="gotoStats" type="submit" value="" /> </form> </div> <div class="membersListRow"> <span class="hoverstateBorder"></span> <span class="avatar"><img src="http://services.runescape.com/m=avatar-rs/brokensteel/chat.png?cachebust=1529804535501" alt="brokensteel" title="" /></span> <span class="name">brokensteel</span> <span class="clanRank">Deputy Owner</span> <span class="proStatus"></span> <span class="totalXP">20,634,741</span> <span class="kills">10</span> <span class="onlineStatus"> <span class="imageIcon"> <img alt="online" src="http://www.runescape.com/img/global/myprofile/icon-status-red.png"> </span> <span class="world"> Offline </span> </span> <span class="hoverstate"></span> <form action="http://services.runescape.com/m=hiscore/compare.ws" method="post" class="viewStats"> <input type="hidden" name="user1" value="brokensteel" /> <input class="gotoStats" type="submit" value="" /> </form> </div> <div class="membersListRow"> <span class="hoverstateBorder"></span> <span class="avatar"><img src="http://services.runescape.com/m=avatar-rs/Robertjones6/chat.png?cachebust=1529804535501" alt="Robertjones6" title="" /></span> <span class="name">Robertjones6</span> <span class="clanRank">Deputy Owner</span> <span class="proStatus"></span> <span class="totalXP">1,149,030</span> <span class="kills">0</span> <span class="onlineStatus"> <span class="imageIcon"> <img alt="online" src="http://www.runescape.com/img/global/myprofile/icon-status-red.png"> </span> <span class="world"> Offline </span> </span> <span class="hoverstate"></span> <form action="http://services.runescape.com/m=hiscore/compare.ws" method="post" class="viewStats"> <input type="hidden" name="user1" value="Robertjones6" /> <input class="gotoStats" type="submit" value="" /> </form> </div> </body></html> HTML; $doc = new DOMDocument(); $doc->loadHTML($data); $xpath = new DOMXpath($doc); $elements = $xpath->query("/html/body//div[@class='membersListRow']"); if (!is_null($elements)) { foreach ($elements as $element) { $username = trim($xpath->query("//span[@class='name']", $element)->item(0)->nodeValue); $world = trim($xpath->query("//span[@class='world']", $element)->item(0)->nodeValue); echo ($world === 'Offline') ? "{$username} is on {$world}\n" : "{$username} is offline\n"; } }
based on vBERS
Output for 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.30 - 7.2.6, 7.3.0alpha1 - 7.3.0beta1
Output for 7.2.7
x Appolyon x is offline x Appolyon x is offline x Appolyon x is offline x Appolyon x is offline