3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = <<<END <table class="behaviourtable table"> <tr> <th>Existing column1</th> <th>Existing column2</th> <th>Existing column3</th> </tr><tr> <td>A</td> <td>B</td> <td>C</td> </tr><tr> <td>D</td> <td>E</td> <td>F</td> </tr><tr> <td class="text-info">G</td> </tr> </table> END; $dom = new DOMDocument();//Loads DOM document $dom->loadHTML($str);//Loads HTML from a previously set variable $xpath = new DOMXPath($dom); $tables = $xpath->query('//table[@class="behaviourtable table"]');//Get only table from HTML $commsTable = ''; foreach ($tables as $table) { $commsTable .= $dom->saveXML($table); } $commsHTML = new DOMDocument(); $commsHTML->loadHTML($commsTable); $tr = $commsHTML->getElementsByTagName('tr'); $th = $commsHTML->createElement('th', 'Comment'); $tr->item(0)->appendChild($th); $xpathcomms = new DOMXPath($commsHTML); $comments = $xpathcomms->query('//td[@class="text-info"]'); if($comments->length > 0){ foreach($comments as $comment){ $parent = $comment->parentNode; $parent->previousSibling->appendChild($comment); } } echo $commsHTML->saveHTML();
Output for git.master, git.master_jit, rfc.property-hooks
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html><body><table class="behaviourtable table"><tr><th>Existing column1</th> <th>Existing column2</th> <th>Existing column3</th> <th>Comment</th></tr><tr><td>A</td> <td>B</td> <td>C</td> </tr><tr><td>D</td> <td>E</td> <td>F</td> <td class="text-info">G</td></tr><tr> </tr></table></body></html>

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:
32.37 ms | 402 KiB | 8 Q