3v4l.org

run code in 300+ PHP versions simultaneously
<?php $bbcode = <<<BBCODE [b]Check out this demo[/b] ¯\_(ツ)_/¯ [table] [**]header1[||]header2[||]header3[||]...[/**] [*]child1.1[|]child1.2[|]child1.3[|]... [*]child2.1[|]child2.2[|]child2.3[|]... [*]child3.1[|]child3.2[|]child3.3[|]... [*]...[|]...[|]...[|]... [/table] simple text [table] [**]a 1[||]and a 2[/**] [*]A[|]B [*]C[|]D [/table] [s]3, you're out[/s] blah BBCODE; function BBTableToHTML($m) { return "<table class=\"ui compact stripet yellow table\">\n" . preg_replace_callback_array( [ '~\[\*\*]([^[]*(?:\[(?!/?\*\*])[^[]*)*)\[/\*\*]~' => 'BBTHeadToHTML', '~(?:\[\*].*\R*)+~' => 'BBTBodyToHTML', '~\[\*](.*)~' => 'BBTBodyRowToHTML' ], $m[1] ) . "</table>"; } function BBTHeadToHTML($m) { return "\t<thead>\n" . "\t\t<tr>\n\t\t\t<th>" . str_replace('[||]', "</th>\n\t\t\t<th>", $m[1]) . "</th>\n\t\t</tr>\n" . "\t</thead>"; } function BBTBodyToHTML($m) { return "\t<tbody>\n{$m[0]}\t</tbody>\n"; } function BBTBodyRowToHTML($m) { return "\t\t<tr>\n\t\t\t<td>" . str_replace('[|]', "</td>\n\t\t\t<td>", $m[1]) . "</td>\n\t\t</tr>"; } echo preg_replace_callback( '~\[table]\R*([^[]*(?:\[(?!/?table])[^[]*)*)\R*\[/table]~', 'BBTableToHTML', $bbcode );
Output for git.master, git.master_jit, rfc.property-hooks
[b]Check out this demo[/b] ¯\_(ツ)_/¯ <table class="ui compact stripet yellow table"> <thead> <tr> <th>header1</th> <th>header2</th> <th>header3</th> <th>...</th> </tr> </thead> <tbody> <tr> <td>child1.1</td> <td>child1.2</td> <td>child1.3</td> <td>...</td> </tr> <tr> <td>child2.1</td> <td>child2.2</td> <td>child2.3</td> <td>...</td> </tr> <tr> <td>child3.1</td> <td>child3.2</td> <td>child3.3</td> <td>...</td> </tr> <tr> <td>...</td> <td>...</td> <td>...</td> <td>...</td> </tr> </tbody> </table> simple text <table class="ui compact stripet yellow table"> <thead> <tr> <th>a 1</th> <th>and a 2</th> </tr> </thead> <tbody> <tr> <td>A</td> <td>B</td> </tr> <tr> <td>C</td> <td>D</td> </tr> </tbody> </table> [s]3, you're out[/s] blah

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:
29.97 ms | 407 KiB | 5 Q