*/
function html_extract_title($html)
{
- if (preg_match('!<title>(.*)</title>!is', $html, $matches)) {
- return trim(str_replace("\n", ' ', $matches[1]));
+ if (preg_match('!<title.*?>(.*?)</title>!is', $html, $matches)) {
+ return trim(str_replace("\n", '', $matches[1]));
}
return false;
}
function html_extract_charset($html)
{
// Get encoding specified in HTML header.
- preg_match('#<meta .*charset="?([^">/]+)"? */?>#Usi', $html, $enc);
+ preg_match('#<meta .*charset=["\']?([^";\'>/]+)["\']? */?>#Usi', $html, $enc);
if (!empty($enc[1])) {
return strtolower($enc[1]);
}
return false;
}
+
+/**
+ * Count private links in given linklist.
+ *
+ * @param array $links Linklist.
+ *
+ * @return int Number of private links.
+ */
+function count_private($links)
+{
+ $cpt = 0;
+ foreach ($links as $link) {
+ $cpt = $link['private'] == true ? $cpt + 1 : $cpt;
+ }
+ return $cpt;
+}