| @@ 2491-2509 (lines=19) @@ | ||
| 2488 | * - Code html de la balise, sinon rien |
|
| 2489 | * - Tableau de résultats, si tableau en entrée. |
|
| 2490 | **/ |
|
| 2491 | function extraire_balise($texte, $tag = 'a') { |
|
| 2492 | if (is_array($texte)) { |
|
| 2493 | array_walk( |
|
| 2494 | $texte, |
|
| 2495 | function(&$a, $key, $t){ |
|
| 2496 | $a = extraire_balise($a, $t); |
|
| 2497 | }, |
|
| 2498 | $tag |
|
| 2499 | ); |
|
| 2500 | ||
| 2501 | return $texte; |
|
| 2502 | } |
|
| 2503 | ||
| 2504 | if (preg_match( |
|
| 2505 | ",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS", |
|
| 2506 | $texte, $regs)) { |
|
| 2507 | return $regs[0]; |
|
| 2508 | } |
|
| 2509 | } |
|
| 2510 | ||
| 2511 | /** |
|
| 2512 | * Extrait toutes les balises html du type demandé |
|
| @@ 2535-2555 (lines=21) @@ | ||
| 2532 | * - Liste des codes html des occurrences de la balise, sinon tableau vide |
|
| 2533 | * - Tableau de résultats, si tableau en entrée. |
|
| 2534 | **/ |
|
| 2535 | function extraire_balises($texte, $tag = 'a') { |
|
| 2536 | if (is_array($texte)) { |
|
| 2537 | array_walk( |
|
| 2538 | $texte, |
|
| 2539 | function(&$a, $key, $t){ |
|
| 2540 | $a = extraire_balises($a, $t); |
|
| 2541 | }, |
|
| 2542 | $tag |
|
| 2543 | ); |
|
| 2544 | ||
| 2545 | return $texte; |
|
| 2546 | } |
|
| 2547 | ||
| 2548 | if (preg_match_all( |
|
| 2549 | ",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS", |
|
| 2550 | $texte, $regs, PREG_PATTERN_ORDER)) { |
|
| 2551 | return $regs[0]; |
|
| 2552 | } else { |
|
| 2553 | return array(); |
|
| 2554 | } |
|
| 2555 | } |
|
| 2556 | ||
| 2557 | /** |
|
| 2558 | * Indique si le premier argument est contenu dans le second |
|