PluginProbe
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript / 1.9.5
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript v1.9.5
4.1.16 4.1.15 4.1.14 4.1.13 4.1.12 4.1.11 4.1.10 4.0.30 4.0.29 4.0.28 4.0.27 4.0.26 4.0.24 4.0.25 4.0.23 4.0.22 4.0.21 4.0.19 4.0.18 4.0.17 4.0.16 1.9.3 1.9.4 1.9.5 1.9.6 All 170 releases
searchpro / simplehtmldom / example / simple_html_dom_utility.php

simple_html_dom_utility.php in BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript 1.9.5, at simplehtmldom/example/simple_html_dom_utility.php

35 lines 893 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 include_once('../simple_html_dom.php');
3
4 // -----------------------------------------------------------------------------
5 // remove HTML comments
6 function html_no_comment($url) {
7 // create HTML DOM
8 $html = file_get_html($url);
9
10 // remove all comment elements
11 foreach($html->find('comment') as $e)
12 $e->outertext = '';
13
14 $ret = $html->save();
15
16 // clean up memory
17 $html->clear();
18 unset($html);
19
20 return $ret;
21 }
22
23 // -----------------------------------------------------------------------------
24 // search elements that contains an specific text
25 function find_contains($html, $selector, $keyword, $index=-1) {
26 $ret = array();
27 foreach ($html->find($selector) as $e) {
28 if (strpos($e->innertext, $keyword)!==false)
29 $ret[] = $e;
30 }
31
32 if ($index<0) return $ret;
33 return (isset($ret[$index])) ? $ret[$index] : null;
34 }
35 ?>