| @@ 378-388 (lines=11) @@ | ||
| 375 | * |
|
| 376 | * @return string|null with the title, if its found. |
|
| 377 | */ |
|
| 378 | public function getTitleFromFirstH1($text) |
|
| 379 | { |
|
| 380 | $matches = []; |
|
| 381 | $title = null; |
|
| 382 | ||
| 383 | if (preg_match("#<h1.*?>(.*)</h1>#", $text, $matches)) { |
|
| 384 | $title = strip_tags($matches[1]); |
|
| 385 | } |
|
| 386 | ||
| 387 | return $title; |
|
| 388 | } |
|
| 389 | ||
| 390 | ||
| 391 | ||
| @@ 399-409 (lines=11) @@ | ||
| 396 | * |
|
| 397 | * @return string|null with the title, if its found. |
|
| 398 | */ |
|
| 399 | public function getTitleFromFirstHeader($text) |
|
| 400 | { |
|
| 401 | $matches = []; |
|
| 402 | $title = null; |
|
| 403 | ||
| 404 | if (preg_match("#<h[1-6].*?>(.*)</h[1-6]>#", $text, $matches)) { |
|
| 405 | $title = strip_tags($matches[1]); |
|
| 406 | } |
|
| 407 | ||
| 408 | return $title; |
|
| 409 | } |
|
| 410 | ||
| 411 | ||
| 412 | ||