remove.md in BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript 1.9.7, at simplehtmldom/manual/docs/api/simple_html_dom_node/remove.md
| 1 | # remove |
| 2 | |
| 3 | ```php |
| 4 | remove ( ) |
| 5 | ``` |
| 6 | |
| 7 | Removes the current node recursively from the DOM. |
| 8 | Does nothing if the node has no parent (root node); |
| 9 | |
| 10 | **Example** |
| 11 | |
| 12 | ```php |
| 13 | $html = str_get_html(<<<EOD |
| 14 | <html> |
| 15 | <body> |
| 16 | <table> |
| 17 | <tr><th>Title</th></tr> |
| 18 | <tr><td>Row 1</td></tr> |
| 19 | </table> |
| 20 | </body> |
| 21 | </html> |
| 22 | EOD |
| 23 | ); |
| 24 | |
| 25 | $table = $html->find('table', 0); |
| 26 | $table->remove(); |
| 27 | |
| 28 | echo $html; |
| 29 | |
| 30 | /** |
| 31 | * Returns |
| 32 | * |
| 33 | * <html> <body> </body> </html> |
| 34 | */ |
| 35 | ``` |
| 36 | |
| 37 | **Remarks** |
| 38 | |
| 39 | * Whitespace immediately **before** the removed node will remain in the DOM. |