Skip to content

Commit

Permalink
[+]: add one more example
Browse files Browse the repository at this point in the history
  • Loading branch information
voku committed Jan 27, 2022
1 parent d2404c1 commit 031f043
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions example/example_remove_content_from_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

use voku\helper\HtmlDomParser;

require_once '../vendor/autoload.php';

$templateHtml = '
<table>
<tr>
<td>
text 1
</td>
<td>
<span class="delete">DELETE</span>
</td>
</tr>
<tr>
<td>
text 2
</td>
<td>
</td>
</tr>
<tr>
<td>
text 3
</td>
<td>
<span class="delete">DELETE</span>
</td>
</tr>
</table>
';

// remove: "<br>" from "<ul>"
$htmlTmp = HtmlDomParser::str_get_html($templateHtml);
foreach ($htmlTmp->findMulti('tr') as $tr) {
foreach ($tr->findMulti('.delete') as $spanDelete) {
$tr->outerhtml = '';
}
}

$templateHtml = $htmlTmp->save();

// dump contents
echo $templateHtml;

0 comments on commit 031f043

Please sign in to comment.