Forum Moderators: coopster
$content = '<td class="data2">1st Information</td><td class="data2">2nd Information</td><td class="data2">3rd Information</td>';
i want to be able to get the information between the <td class="data2"> and the </td> tag and loop it.
So for example once it is done, instead of having the following:
<td class="data2">1st Information</td>
<td class="data2">2nd Information</td>
<td class="data2">3rd Information</td>
It should be the following:
1st Information<br>
2nd Information<br>
3rd Information<br>
Can anyone please help?
Thanks
$content = '<td class="data2">1st Information</td><td class="data2">2nd Information</td><td class="data2">3rd Information</td>';
$store = array();if (preg_match_all("/<td class=\"data2\">(.*?)<\/td>/si", $content, $aux))
{
$store[] = $aux[0];
}var_dump($store);
[edited by: NomikOS at 3:34 pm (utc) on Dec. 4, 2009]
# to isolate each data cell use PREG_SET_ORDER flag:if (preg_match_all("/<td class=\"data2\">(.*?)<\/td><td class=\"data2\">(.*?)<\/td><td class=\"data2\">(.*?)<\/td>/si", $content, $aux, PREG_SET_ORDER))
{
foreach ($aux as $aux2)
{
$store['1st Information'][] = $aux2[1];
$store['2st Information'][] = $aux2[2];
$store['3st Information'][] = $aux2[3];
}
}