| ');
$html = preg_replace('/ | ]*>([^<]+)<\/th>/', '\1', $html);
$html = preg_replace('/ | ]*>([^<]+)<\/td>/', '\1', $html);
$t = preg_split('/(]*>[^<]+<\/h2>)/', $html, -1, PREG_SPLIT_DELIM_CAPTURE);
$r = [];
$count = \count($t);
$p1 = '([^<]+)<\/info>';
$p2 = '/' . $p1 . '\s*' . $p1 . '\s*' . $p1 . '/';
$p3 = '/' . $p1 . '\s*' . $p1 . '/';
for ($i = 1; $i < $count; $i++)
{
if (preg_match('/]*>([^<]+)<\/h2>/', $t[$i], $matchs))
{
$name = trim($matchs[1]);
$vals = explode("\n", $t[$i + 1]);
foreach ($vals AS $val)
{
// 3cols
if (preg_match($p2, $val, $matchs))
{
$r[$name][trim($matchs[1])] = [trim($matchs[2]), trim($matchs[3]),];
}
// 2cols
elseif (preg_match($p3, $val, $matchs))
{
$r[$name][trim($matchs[1])] = trim($matchs[2]);
}
}
}
}
return $r;
}
}
|