PHP - Inserting Text above a given pattern

ساخت وبلاگ

Vote count: 0

I have number of html files and each file has

<p>Some string</p>
<p>Some text</p>
<p>Some other text</p>
<p>Above this i want to add a string</p>
<p>Completed On: dd.mm.yyyy</p>
Rest of HTML page

The string "Completed On:" occurs only once in entire page.

Above the "Above this i want to add a string" --para I want to add a string say -- IDENTIFIER01.

The text Above this i want to add a string is variable and not fixed like Completed On: else i would have used patte matching.

How can this be done in PHP?

I am reading the file and keeping only needed html tags

$html = file_get_contents('file.html');
$strip = strip_tags("$html","<b>,<p>,<br>,<blockquote>,<ul>,<ol>,<li>,<u>,<i>,");

So would want to update $strip to add the string IDENTIFIER01 before moving to next stage of the code.

Thanks.

asked 2 mins ago

- - , .

back soft...
ما را در سایت back soft دنبال می کنید

برچسب : نویسنده : استخدام کار backsoft بازدید : 346 تاريخ : جمعه 30 بهمن 1394 ساعت: 2:37