3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <table border="0" cellpadding="0" cellspacing="0" width="100%" class="Table2"> <tbody><tr> <td width="1%" valign="top" class="Title2">&nbsp;</td> <td width="65%" valign="top" class="Title2">Subject</td> <td width="1%" valign="top" class="Title2">&nbsp;</td> <td width="14%" valign="top" align="Center" class="Title2">Last Update</td> <td width="1%" valign="top" class="Title2">&nbsp;</td> <td width="8%" valign="top" align="Center" class="Title2">Replies</td> <td width="1%" valign="top" class="Title2">&nbsp;</td> <td width="9%" valign="top" align="Center" class="Title2">Views</td> </tr> <tr> <td width="1%" height="25">&nbsp;</td> <td width="64%" height="25" class="FootNotes2"><a href="/files/forum/2017/1/837110.php" target="_top" class="Links2">Serious dedicated study partner for U World</a> - step12013</td> <td width="1%" height="25">&nbsp;</td> <td width="14%" height="25" class="FootNotes2" align="center">02/11/17 01:50</td> <td width="1%" height="25">&nbsp;</td> <td width="8%" height="25" align="Center" class="FootNotes2">10</td> <td width="1%" height="25">&nbsp;</td> <td width="9%" height="25" align="Center" class="FootNotes2">318</td> </tr> <tr> <td width="1%" height="25">&nbsp;</td> <td width="64%" height="25" class="FootNotes2"><a href="/files/forum/2017/1/837999.php" target="_top" class="Links2">some text</a> - step12013</td> <td width="1%" height="25">&nbsp;</td> <td width="14%" height="25" class="FootNotes2" align="center">02/11/17 01:50</td> <td width="1%" height="25">&nbsp;</td> <td width="8%" height="25" align="Center" class="FootNotes2">10</td> <td width="1%" height="25">&nbsp;</td> <td width="9%" height="25" align="Center" class="FootNotes2">318</td> </tr> </tbody> </table> HTML; $dom=new DOMDocument; $dom->loadHTML($html); $xpath = new DOMXPath($dom); foreach ($xpath->evaluate("//td[@class = 'FootNotes2']/a") as $node) { // target a tags that have <td class="FootNotes2"> as parent $result[]=['href' => $node->getAttribute('href'), 'text' => $node->nodeValue]; // extract/store the href and text values if (sizeof($result) == 10) { break; } // set a limit of 10 rows of data } if (isset($result)) { echo "<ul>\n"; foreach ($result as $data) { echo "\t<li class=\"itemtitle\"><a href=\"{$data['href']}\" target=\"_blank\">{$data['text']}</a></li>\n"; } echo "</ul>"; }
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0 - 8.5.1
<ul> <li class="itemtitle"><a href="/files/forum/2017/1/837110.php" target="_blank">Serious dedicated study partner for U World</a></li> <li class="itemtitle"><a href="/files/forum/2017/1/837999.php" target="_blank">some text</a></li> </ul>
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
154.8 ms | 407 KiB | 5 Q