I can't seem to get the hang of regular expressions in php. Specifically, the group capturing part.
I have a string that looks like this
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="List">
<tr class='row_type_1'>
<td class="time">
3:45 pm
</td>
<td class="name">
Kira
</td>
</tr>
<tr class='row_type_2'>
<td class="time">
4:00 pm
</td>
<td class="name">
Near
</td>
</tr>
</table>
And I want my array to look like this
Array
(
[0] => Array
(
[0] => 3:45 pm
[1] => Kira
)
[1] => Array
(
[0] => 4:00 pm
[1] => Near
)
)
I want to use only preg_match, and not explode, array_keys or loops. Took me a while to figure out I needed a /s for .* to count line breaks; I'm really eager to see the pattern and the capture syntax.
Edit: The pattern would just need something like (row_type_1|row_type_2) to capture the only two types of row in the table I want data from. For example, after row_type_2 came row_type_3, followed by row_type_1, then row_type_3 would be ignored and the array would only add data from row_type_1 like what I have below.
Array
(
[0] => Array
(
[0] => 3:45 pm
[1] => Kira
)
[1] => Array
(
[0] => 4:00 pm
[1] => Near
)
[2] => Array
(
[0] => 5:00 pm
[1] => L
)
)