Condition: I have a peace of html code from wysiwig (Brief). I need to inject readmore link to the last paragrpaph (p-tag)
public function injectReadMore($html){
if( $this->is_html($html) ){
return preg_replace('#\<\/p\>$#isU',' <a href="javascript:void(0)" class="toggle-full-dsc">Читать полностью</a>$0', $html);
} else {
return '<p>'.$html.' <a href="javascript:void(0)" class="toggle-full-dsc">Читать полностью</a></p>';
}
}
Yep. What i wrote it's not right. Cuz if
$html = '<p>sdfgsdfg</p><div><p>sdfgsdfg</p> </div> ';
Fail.
Tried regexp's:
'#\<\/p\>[^p]+?$#isU'
'#\<\/p\>[^\/p]+?$#isU'
'#\<\/p\>[^[\/p]]+?$#isU'
and the same variants of RegExp. I don't understand something, maybe all;)
Help pls. Thanks, Brothers.
