Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <offer id="81403" available="true">
- <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>
- <seller_warranty>true</seller_warranty><store>true</store><delivery>true</delivery><vendor>Sony</vendor><price>273</price>
- <currencyId>RUB</currencyId>
- <categoryId>1813</categoryId>
- <picture>http://mysite.net/upload/iblock/bb9/8544043f-b933-4b6f-af15-c05be9b291d1_bdfc495c-2226-11e6-9a8e-bcee7b5aca2b.jpeg</picture>
- <name>Шлейф SonyEricsson T707 межплатный Оригинал Hello</name>
- <description></description>
- <sales_notes>Скидка 5% при оплате VISA, MasterCard</sales_notes>
- </offer>
- <?php
- // подключаем класс simple_html_dom для разбора html
- include_once('simple_html_dom.php');
- $html = file_get_html('http://www.google.com/');
- // что ищем
- $findme = 'Hello';
- // Find all
- foreach($html->find('offer') as $element) {
- $mystring = $element->innertext();
- $isFind = strpos($mystring, $findme);
- if ($isFind === false) {
- //не найдено
- //echo "Строка '$findme' не найдена в строке '$mystring1'";
- //if ($isFind === false)
- } else {
- //зачищаем
- $element->innertext('');
- }//else if ($isFind === false)
- }//foreach($html->find('offer') as $element)
- echo $html->innertext();
- $string = '<offer id="81403" available="true">
- <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>
- <seller_warranty>true</seller_warranty><store>true</store><delivery>true</delivery><vendor>Sony</vendor><price>273</price>
- <currencyId>RUB</currencyId>
- <categoryId>1813</categoryId>
- <picture>http://mysite.net/upload/iblock/bb9/8544043f-b933-4b6f-af15-c05be9b291d1_bdfc495c-2226-11e6-9a8e-bcee7b5aca2b.jpeg</picture>
- <name>Шлейф SonyEricsson T707 межплатный Оригинал Hello</name>
- <description></description>
- <sales_notes>Скидка 5% при оплате VISA, MasterCard</sales_notes>
- </offer>';
- $need = 'Hello';
- $pattern = '~<(w+)>.*'. preg_quote($need, '~') .'.*</1>~';
- $string = preg_replace($pattern, '', $string);
- echo '<pre>'; print_r($string); echo '</pre>';
- /* Будет удалена вся строка вместе с тегом <name>:
- <name>Шлейф SonyEricsson T707 межплатный Оригинал Hello</name>
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement