Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. <?php
  2. // подключаем класс simple_html_dom для разбора html
  3. include_once('simple_html_dom.php');
  4.  
  5. $html = file_get_html('http://www.google.com/');
  6. // что ищем
  7. $findme = 'Hello';
  8.  
  9. // Find all
  10. foreach($html->find('offer') as $element) {
  11. $mystring = $element->innertext();
  12. $isFind = strpos($mystring, $findme);
  13. if ($isFind === false) {
  14. //не найдено
  15. //echo "Строка '$findme' не найдена в строке '$mystring1'";
  16. //if ($isFind === false)
  17. } else {
  18. //зачищаем
  19. $element->innertext('');
  20. }//else if ($isFind === false)
  21. }//foreach($html->find('offer') as $element)
  22. echo $html->innertext();
  23.  
  24. $str = '<offer>Hello</offer>';
  25.  
  26. echo preg_replace('~<offer>Hello</offer>~i', '', $str);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement