3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = '<html> <body> <table> <thead> <tr> <th>Name</th> <th>Date</th> </tr> </thead> <tbody> <tr> <td>Chad</td> <td>10/23/1996</td> </tr> <tr> <td>Rebecca</td> <td>05/03/2001</td> </tbody> </table> </body> </html>'; $dom = new DOMDocument(); $dom->loadHTML($html); $headers = $dom->getElementsByTagName('th'); foreach($headers as $header) { $keys[] = strtolower($header->nodeValue); } $rows = $dom->getElementsByTagName('tbody')->item(0)->getElementsByTagName('tr'); $result = []; foreach($rows as $row) { $item = []; $cells = $row->getElementsByTagName('td'); foreach($keys as $i => $key) { $item[$key] = $cells->item($i)->nodeValue; } $result[] = $item; } var_dump($result);
Output for git.master, git.master_jit, rfc.property-hooks
array(2) { [0]=> array(2) { ["name"]=> string(4) "Chad" ["date"]=> string(10) "10/23/1996" } [1]=> array(2) { ["name"]=> string(7) "Rebecca" ["date"]=> string(10) "05/03/2001" } }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
36.84 ms | 401 KiB | 8 Q