3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <html> <head> </head> <body> <table> <tbody> <tr> <td>header1</td> <td>header2</td> <td>header3</td> </tr> <tr> <td>content1</td> <td>content2</td> <td>content3</td> </tr> <tr> <td>test1</td> <td>test2</td> <td>test3</td> </tr> </tbody> </table> </body> </html> HTML; $dom = new DOMDocument(); $dom->loadHTML($html); $result = []; foreach ($dom->getElementsByTagName('tr') as $i => $row) { foreach ($row->getElementsByTagName('td') as $c => $cell) { $result[$c][$i] = $cell->nodeValue; } } var_export($result);
Output for rfc.property-hooks, git.master, git.master_jit
array ( 0 => array ( 0 => 'header1', 1 => 'content1', 2 => 'test1', ), 1 => array ( 0 => 'header2', 1 => 'content2', 2 => 'test2', ), 2 => array ( 0 => 'header3', 1 => 'content3', 2 => 'test3', ), )

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:
42.38 ms | 1152 KiB | 4 Q