I have a string variable in PHP which is like
<html>
<body>
<div style="height: 10px; line-height: 10px;">
</div>
</body>
</html>
I want to split that String into two pieces
String 1
<html>
<body>
<div style="height: 10px; line-height: 10px;">
String 2
</div>
</body>
</html>
And then will insert some content into that DIV.
Note: Above string is just a sample to explain what I want, I have an HTML markup of 1000+ lines
As someone asked "What is your effort in PHP towards the query??"
$pieces = split('<div style="height: 10px; line-height: 10px;">', $template);
But it contains the whole markup not the splited one
Well you could have your variable like
<html>
<body>
<div style="height: 10px; line-height: 10px;">
xyz123
</div>
</body>
</html>
And then use php
explode function like
$result = explode( 'xyz123', $yourvar );
then access the two parts like
$result[0] and $result[1]
Note: xyz123 is used as a unique string for demo purpose.
Do you need insert your content into a div? Try it:
$new = str_replace('<div style="height: 10px; line-height: 10px;">', '<div style="height: 10px; line-height: 10px;">' . $yourContent, $template);