Код: Выделить всё
1. Question [b]1[/b]
2. You have [u]Question[/u][b]1[/b]
3. Question [b]3[/b]
Код: Выделить всё
[
0 => 'Question 1', // Or 'Question [b]1[/b]' is better
1 => 'You have Question 2',
2 => 'Question 3'
]
Код: Выделить всё
$results = [];
$questions = $crawler->filterXPath('//*[contains(@class, "body")]/text()[normalize-space()][following-sibling::input]');
$questions = $questions->each(function($c) use (&$results) {
$line = trim($c->text());
if(preg_match('/^[0-9]{1,2}\./', $line, $matches) == true) {
$number = $matches[0];
if(is_numeric($number) && $number != '') {
$results[] = trim(str_replace($number, '', $line));
}
} elseif(!empty($results)) {
$results[count($results) - 1] .= '\n'. $line;
}
});
return $results;
Подробнее здесь: https://stackoverflow.com/questions/379 ... ng-sibling
Мобильная версия