xpath('//listitem/para/ref') as $oRef) { if (!$oRef->asXML()) continue; // get hook reference id $sKey = dom_import_simplexml($oRef)->nodeValue; // generate URL with hook description and anchor $a = explode('_1', $oRef['refid'], 2); $sUrl = $sBaseDocUrl . "{$a[0]}.html"; $sAnchor = $a[1]; // get page content with hook desription $s = ''; if (!isset($aUrls[$sUrl])) { $s = file_get_contents($sUrl); $aUrls[$sUrl] = $s; } else { $s = $aUrls[$sUrl]; } // parse page content to get hook snippet $iStart = mb_strpos($s, '"' . $sAnchor . '"'); if ($iStart === false) continue; $iEnd = mb_strpos($s, '
\n"; $aOutput[$sKey] = $bMarkdown ? $sSnippetMd : $sSnippetHtmlFixed; ++$i; // if ($i>10) // break; } // sort hooks asort($aOutput); // output echo "

$i Hooks


\n\n"; if ($bMarkdown) { echo '
' . implode("\n\n", $aOutput) . '
'; } else { echo implode("\n\n", $aOutput); }