Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. <offer id="81403" available="true">
  2. <url>http://mysite.net/catalog/all/zapchasti_dlya_telefonov_i_noutbukov/zapchasti_dlya_telefonov/81403_shleyf_sonyericsson_t707_mezhplatnyy_original.html?r1=<?echo $strReferer1; ?>&r2=<?echo $strReferer2; ?>&from=market</url>
  3. <seller_warranty>true</seller_warranty><store>true</store><delivery>true</delivery><vendor>Sony</vendor><price>273</price>
  4. <currencyId>RUB</currencyId>
  5. <categoryId>1813</categoryId>
  6. <picture>http://mysite.net/upload/iblock/bb9/8544043f-b933-4b6f-af15-c05be9b291d1_bdfc495c-2226-11e6-9a8e-bcee7b5aca2b.jpeg</picture>
  7. <name>Шлейф SonyEricsson T707 межплатный Оригинал Hello</name>
  8. <description></description>
  9. <sales_notes>Скидка 5% при оплате VISA, MasterCard</sales_notes>
  10. </offer>
  11.  
  12. <?php
  13. // подключаем класс simple_html_dom для разбора html
  14. include_once('simple_html_dom.php');
  15.  
  16. $html = file_get_html('http://www.google.com/');
  17. // что ищем
  18. $findme = 'Hello';
  19.  
  20. // Find all
  21. foreach($html->find('offer') as $element) {
  22. $mystring = $element->innertext();
  23. $isFind = strpos($mystring, $findme);
  24. if ($isFind === false) {
  25. //не найдено
  26. //echo "Строка '$findme' не найдена в строке '$mystring1'";
  27. //if ($isFind === false)
  28. } else {
  29. //зачищаем
  30. $element->innertext('');
  31. }//else if ($isFind === false)
  32. }//foreach($html->find('offer') as $element)
  33. echo $html->innertext();
  34.  
  35. $string = '<offer id="81403" available="true">
  36. <url>http://mysite.net/catalog/all/zapchasti_dlya_telefonov_i_noutbukov/zapchasti_dlya_telefonov/81403_shleyf_sonyericsson_t707_mezhplatnyy_original.html?r1=<?echo $strReferer1; ?>&r2=<?echo $strReferer2; ?>&from=market</url>
  37. <seller_warranty>true</seller_warranty><store>true</store><delivery>true</delivery><vendor>Sony</vendor><price>273</price>
  38. <currencyId>RUB</currencyId>
  39. <categoryId>1813</categoryId>
  40. <picture>http://mysite.net/upload/iblock/bb9/8544043f-b933-4b6f-af15-c05be9b291d1_bdfc495c-2226-11e6-9a8e-bcee7b5aca2b.jpeg</picture>
  41. <name>Шлейф SonyEricsson T707 межплатный Оригинал Hello</name>
  42. <description></description>
  43. <sales_notes>Скидка 5% при оплате VISA, MasterCard</sales_notes>
  44. </offer>';
  45.  
  46. $need = 'Hello';
  47. $pattern = '~<(w+)>.*'. preg_quote($need, '~') .'.*</1>~';
  48. $string = preg_replace($pattern, '', $string);
  49.  
  50. echo '<pre>'; print_r($string); echo '</pre>';
  51. /* Будет удалена вся строка вместе с тегом <name>:
  52. <name>Шлейф SonyEricsson T707 межплатный Оригинал Hello</name>
  53. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement