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