Я хочу импортировать только тексты, содержащие только class="item-name"
Not и class="item-name active"
Как вы думаете, как я могу применить импорт? >
HTML-код:
[*]
Category
[*]
Category 1
[*]
Category 2
[*]
Title
Мой PHP-код:
if ($html !== false) {
$prod['id']=$html->find('span.code',0)->plaintext;
$j=0;
while (isset($html->find('span.item-name',$j)->plaintext)) {
$cats[]=str_replace(['.',';'],' ',html_entity_decode($html->find('span.item-name',$j)->plaintext));
$j++;
}
$prod['category']=implode(', ',$cats);
unset($cats);
}
ОБНОВЛЕНИЕ, исправляю
if ($html !== false) {
$prod['id']=$html->find('span.code',0)->plaintext;
$j=0;
while (isset($html->find('a.item',$j)->plaintext)) {
$cats[]=str_replace([' ',''',';'],' ',html_entity_decode($html->find('a.item',$j)->plaintext));
$new = preg_replace(['(\s+)u', '(^\s|\s$)u'], [' ', ''], $cats);
$j++;
}
$prod['category']=implode(', ',$new);
unset($new);
}
Подробнее здесь: https://stackoverflow.com/questions/495 ... g-html-dom