U
U
uaf0x2016-09-15 19:50:22
PHP
uaf0x, 2016-09-15 19:50:22

How to defeat srt_replace?

Greetings, there is an html page, it is necessary to cut off all links leading to 404 from it, I decided to use str_replace, but for some reason it does not work, what is the reason, who will tell you?)
The code that should be deleted

$html = file_get_contents("D:/OpenServer/domains/nfp/blog/index.html");
  $replace =  str_ireplace("/<a(.*?)\/blog6\/find_a_job\/index\.html(.*?)<\/a>/", "anykeyword", $html);
  echo $replace;

And what he must remove
<li class="page_item page-item-1383"><a href="/blog/find_jobs/index.html" title="&lt;a href=&quot;http://site.org/blog6/find-a-job/&quot;&gt;Find Jobs&lt;/a&gt;"><a href="/blog6/find_a_job/index.html">Find Jobs</a></a></li>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2016-09-15
@uaf0x

what is the reason
Mainly because str_replace() doesn't work with regular expressions.
preg_replace();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question