3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str='<div class="table tbl-process-mobile"> <div class="table-cn"> <div class="table-bd"> <table cellspacing="0" id="idd7"> <thead> <tr id="idd9"> <th scope="col"> <span>username</span> </th> <th scope="col"> <span>status</span> </th> <th scope="col"> <span>prefered number</span> </th> <th scope="col"> <span>action</span> </th> </tr> </thead> <tbody id="iddb"> <tr class="even"> <td class="even"> <div>randomusername</div> </td><td class="odd"> <div>0123456789</div> </td><td class="even"> <div>active</div> </td><td class="odd"> <div> <span id="iddc" style="display:none"></span> <a href="xyz" id="idb2"><span>set number</span></a> </div> </td><td class="even"> <div>randomusername</div> </td><td class="odd"> <div>0123456789</div> </td><td class="even"> <div>active</div> </td><td class="odd"> <div> <span id="iddc" style="display:none"></span> <a href="xyz" id="idb2"><span>set number</span></a> </div> </td><td class="even"> <div> <a id="iddd" style="display:none"></a> <a href="xyz" class="action-icon-edit" id="idb3" title="change"> <i>change</i> </a> <a href="xyz" class="action-icon-delete" id="idb4" title="delete"> <i>delete</i> </a> </div> </td> </tr><tr class="odd"> <td class="even"> <div>randomusername2</div> </td><td class="odd"> <div>0987654321</div> </td><td class="even"> <div>active</div> </td><td class="odd"> <div> <span id="idde" style="display:none"></span> <a href="xyz" id="idb5"><span>set number</span></a> </div> </td><td class="even"> <div> <a id="iddf" style="display:none"></a> <a href="xyz" class="action-icon-edit" id="idb6" title="change"> <i>change</i> </a> <a href="xyz" class="action-icon-delete" id="idb7" title="delete"> <i>delete</i> </a> </div> </td> </tr> </tbody> </table> </div> </div> </div>'; $dom = new DOMDocument; $dom->loadHTML($str); $trs = $dom->getElementById("iddb")->getElementsByTagName("tr"); $arr = []; foreach($trs as $key=>$tr){ $tds = $tr->getElementsByTagName("td"); $arr[$key] = [ $tds->item(0)->textContent, $tds->item(1)->textContent, $tds->item(2)->textContent ]; } print_r($arr); ?>
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 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.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Warning: DOMDocument::loadHTML(): ID iddc already defined in Entity, line: 42 in /in/FJIgY on line 88 Warning: DOMDocument::loadHTML(): ID idb2 already defined in Entity, line: 43 in /in/FJIgY on line 88 Array ( [0] => Array ( [0] => randomusername [1] => 0123456789 [2] => active ) [1] => Array ( [0] => randomusername2 [1] => 0987654321 [2] => active ) )
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Warning: DOMDocument::loadHTML(): ID iddc already defined in Entity, line: 42 in /in/FJIgY on line 88 Warning: DOMDocument::loadHTML(): ID idb2 already defined in Entity, line: 43 in /in/FJIgY on line 88 Array ( [0] => Array ( [0] => randomusername [1] => 0123456789 [2] => active ) [1] => Array ( [0] => randomusername2 [1] => 0987654321 [2] => active ) )

preferences:
244.03 ms | 403 KiB | 288 Q