Всем привет. Ребят помогите с регуляркой.
Есть примерно такой кусок кода:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
<div style="white-space: nowrap; margin: 10px">
<div style="white-space: nowrap; padding: 3px;">
<div style="width: 60px; height: 32px; vertical-align: top; display: inline-block;">
<div style="width: 48px; height: 32px; vertical-align: top; display: inline-block; border: 2px solid rgb(255, 255, 255);">
<div style="position: absolute; width: 48px; height: 32px; vertical-align: top; display: inline-block; background-size: contain; background-image: url()"></div>
</div>
</div>
<div style="vertical-align: top; display: inline-block; margin-left: 12px padding: 2px">
<span style="font-size: 18px; color: rgb(255, 255, 255)">Text111</span>
<br>
<span style="font-size: 12px">Subtext111</span>
</div>
</div>
<div style="white-space: nowrap; padding: 3px;">
<div style="width: 60px; height: 32px; vertical-align: top; display: inline-block;">
<div style="width: 48px; height: 32px; vertical-align: top; display: inline-block; border: 2px solid rgb(255, 255, 255);">
<div style="position: absolute; width: 48px; height: 32px; vertical-align: top; display: inline-block; background-size: contain; background-image: url(url2)"></div>
</div>
</div>
<div style="vertical-align: top; display: inline-block; margin-left: 12px padding: 2px">
<span style="font-size: 18px; color: rgb(255, 255, 255)">Text2</span>
<br>
<span style="font-size: 12px">Subtext2</span>
</div>
</div>
</div>
Нужно выбрать для каждого блока внутри:
автор<div style="white-space: nowrap; padding: 3px;">
background-image url, и текст из SPAN
Пробую так:
1.
2.
3.
4.
5.
preg_match_all('/<div style="white-space: nowrap; padding: 3px;">.*<div style=".*background-image: url(.+?)"><\/div>.*<span.*>(.+?)<\/span>.*<span.*>(.+?)<\/span>.*<\/div>.*<\/div>/is', $str, $matches);
unset($matches[0]);
echo '<pre>';
print_r($matches);
echo '</pre>';
Выводит:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
Array
(
[1] => Array
(
[0] => (55)
)
[2] => Array
(
[0] => Text2
)
[3] => Array
(
[0] => Subtext2
)
)
но выводит из последнего блока массив, а надо обработать все. ЧЯДН?
Помогите плз.