Как спарсить значение каждого тд в отдельную переменную?
<td>Vasya </td>
<td>Pupkin </td>
<td>1</td>
<td>15</td>
<td>7</td>
<td>305487</td>
<td>007 </td>
<td>A</td>
<td>M</td>
<td>Q</td>
<td>R</td>
Цитата (walerus @ 18.11.2016 - 14:53) |
хотел посмотреть как с помощью эксплода это сделать |
$txt = '<td>Vasya </td>
<td>Pupkin </td>
<td>1</td>
<td>15</td>
<td>7</td>
<td>305487</td>
<td>007 </td>
<td>A</td>
<td>M</td>
<td>Q</td>
<td>R</td>';
$output = array();
$txt = explode('<td>', $txt);
foreach($txt as $v)
if(stristr($v, '</td>'))
$output[] = substr($v, 0, strpos($v, '</td>'));
$txt = '<td>Vasya </td>
<td>Pupkin </td>
<td>1</td>
<td>15</td>
<td>7</td>
<td>305487</td>
<td>007 </td>
<td>A</td>
<td>M</td>
<td>Q</td>
<td>R</td>';
$output = array();
$txt = explode('<td>', $txt);
foreach($txt as $v)
{
$v = explode('</td>', $v);
if($v[0])
$output[] = $v[0];
}