| @@ 491-501 (lines=11) @@ | ||
| 488 | * |
|
| 489 | * @return string|null with the title, if its found. |
|
| 490 | */ |
|
| 491 | public function getTitleFromFirstH1($text) |
|
| 492 | { |
|
| 493 | $matches = []; |
|
| 494 | $title = null; |
|
| 495 | ||
| 496 | if (preg_match("#<h1.*?>(.*)</h1>#", $text, $matches)) { |
|
| 497 | $title = strip_tags($matches[1]); |
|
| 498 | } |
|
| 499 | ||
| 500 | return $title; |
|
| 501 | } |
|
| 502 | ||
| 503 | ||
| 504 | ||
| @@ 512-522 (lines=11) @@ | ||
| 509 | * |
|
| 510 | * @return string|null with the title, if its found. |
|
| 511 | */ |
|
| 512 | public function getTitleFromFirstHeader($text) |
|
| 513 | { |
|
| 514 | $matches = []; |
|
| 515 | $title = null; |
|
| 516 | ||
| 517 | if (preg_match("#<h[1-6].*?>(.*)</h[1-6]>#", $text, $matches)) { |
|
| 518 | $title = strip_tags($matches[1]); |
|
| 519 | } |
|
| 520 | ||
| 521 | return $title; |
|
| 522 | } |
|
| 523 | ||
| 524 | ||
| 525 | ||