public function getContentsByHeader($sContents, $iHeaderNumber = 2)
{
$_aContents = array();
$_aSplitContents = preg_split('/(<h[' . $iHeaderNumber . ']*[^>]*>.*?<\\/h[' . $iHeaderNumber . ']>)/i', $sContents, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
foreach ($_aSplitContents as $_iIndex => $_sSplitContent) {
if (!preg_match('/<h[' . $iHeaderNumber . ']*[^>]*>(.*?)<\\/h[' . $iHeaderNumber . ']>/i', $_sSplitContent, $_aMatches)) {
continue;
}
if (!isset($_aMatches[1])) {
continue;
}
if (isset($_aSplitContents[$_iIndex + 1])) {
$_aContents[] = array($_aMatches[1], $_aSplitContents[$_iIndex + 1]);
}
}
return empty($_aContents) ? array(array('', $sContents)) : $_aContents;
}