| @@ 417-427 (lines=11) @@ | ||
| 414 | * |
|
| 415 | * @return string|null with the title, if its found. |
|
| 416 | */ |
|
| 417 | public function getTitleFromFirstH1($text) |
|
| 418 | { |
|
| 419 | $matches = []; |
|
| 420 | $title = null; |
|
| 421 | ||
| 422 | if (preg_match("#<h1.*?>(.*)</h1>#", $text, $matches)) { |
|
| 423 | $title = strip_tags($matches[1]); |
|
| 424 | } |
|
| 425 | ||
| 426 | return $title; |
|
| 427 | } |
|
| 428 | ||
| 429 | ||
| 430 | ||
| @@ 438-448 (lines=11) @@ | ||
| 435 | * |
|
| 436 | * @return string|null with the title, if its found. |
|
| 437 | */ |
|
| 438 | public function getTitleFromFirstHeader($text) |
|
| 439 | { |
|
| 440 | $matches = []; |
|
| 441 | $title = null; |
|
| 442 | ||
| 443 | if (preg_match("#<h[1-6].*?>(.*)</h[1-6]>#", $text, $matches)) { |
|
| 444 | $title = strip_tags($matches[1]); |
|
| 445 | } |
|
| 446 | ||
| 447 | return $title; |
|
| 448 | } |
|
| 449 | ||
| 450 | ||
| 451 | ||