Need to remove

<!-- Put this script tag to the <head> of your page --> <script type="text/javascript" src="//vk.com/js/api/openapi.js?137"></script> <!-- Put this div tag to the place, where the Poll block will be -->

from the string using php. That text should disappear or be replaced by a space. The string itself consists of this

 <!-- Put this script tag to the <head> of your page --> <script type="text/javascript" src="//vk.com/js/api/openapi.js?137"></script> <!-- Put this div tag to the place, where the Poll block will be --> <div id="vk_poll"></div> <script type="text/javascript"> VK.Widgets.Poll("vk_poll", {width: 300}, "252624848_44cf7d2c0b8ed9d470"); </script> 
  • remove javascript, jquery, api tags. They do not relate to your question. Use str_replace () if you want to replace the entire line. - DimenSi

1 answer 1

 $main_string = '<!-- Put this script tag to the <head> of your page --> <script type="text/javascript" src="//vk.com/js/api/openapi.js?137"></script> <!-- Put this div tag to the place, where the Poll block will be --> <div id="vk_poll"></div> <script type="text/javascript"> VK.Widgets.Poll("vk_poll", {width: 300}, "252624848_44cf7d2c0b8ed9d470"); </script>'; $pattern = '<!-- Put this script tag to the <head> of your page --> <script type="text/javascript" src="//vk.com/js/api/openapi.js?137"></script> <!-- Put this div tag to the place, where the Poll block will be -->'; $main_string = str_replace($pattern, '', $main_string); 
  • I don’t know how you get the source string and the search pattern, but if you just assign a variable to a file, don’t forget about line breaks. - Solid