Answer the question
In order to leave comments, you need to log in
How to replace tag and quotes with phpquery?
Hello! I scour the site, but the library swears at the characters. I wanted to ask how you can replace double quotes " with single quotes" and the blockquote tag with a div tag in the entire text,
thanks in advance!
foreach ($cont_url2 as $el2) {
$pq2 = pq($el2);
$text2 = $pq2->find('.messageText');
$text2->find('noindex')->remove();
$text2->find('.internalLink')->remove();
$text2->find('.mceSmilie')->remove();
$text2->find('.messageTextEndMarker')->remove();
$text2->find('aside')->remove();
$post_prev = R::dispense('postprev');
if(!empty($text2)) $post_prev->text = $text2;
R::store($post_prev);
}
Answer the question
In order to leave comments, you need to log in
If I understand correctly, then this is phpQuery? This means that noindex must be in square quotes, this is an attribute. Maybe this is the problem? Or maybe it would be better to do so?
<?php
foreach ($cont_url2 as $el2) {
$pq2 = pq($el2);
$text2 = $pq2->find('.messageText');
$text2->remove('[noindex]');
$text2->remove('.internalLink');
$text2->remove('.mceSmilie');
$text2->remove('.messageTextEndMarker');
$text2->remove('aside');
if(!empty($text2)) {
$post_prev = R::dispense('postprev');
$post_prev->text = $text2;
R::store($post_prev);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question