| @@ 2474-2492 (lines=19) @@ | ||
| 2471 | * - Code html de la balise, sinon rien |
|
| 2472 | * - Tableau de résultats, si tableau en entrée. |
|
| 2473 | **/ |
|
| 2474 | function extraire_balise($texte, $tag = 'a') { |
|
| 2475 | if (is_array($texte)) { |
|
| 2476 | array_walk( |
|
| 2477 | $texte, |
|
| 2478 | function(&$a, $key, $t){ |
|
| 2479 | $a = extraire_balise($a, $t); |
|
| 2480 | }, |
|
| 2481 | $tag |
|
| 2482 | ); |
|
| 2483 | ||
| 2484 | return $texte; |
|
| 2485 | } |
|
| 2486 | ||
| 2487 | if (preg_match( |
|
| 2488 | ",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS", |
|
| 2489 | $texte, $regs)) { |
|
| 2490 | return $regs[0]; |
|
| 2491 | } |
|
| 2492 | } |
|
| 2493 | ||
| 2494 | /** |
|
| 2495 | * Extrait toutes les balises html du type demandé |
|
| @@ 2518-2538 (lines=21) @@ | ||
| 2515 | * - Liste des codes html des occurrences de la balise, sinon tableau vide |
|
| 2516 | * - Tableau de résultats, si tableau en entrée. |
|
| 2517 | **/ |
|
| 2518 | function extraire_balises($texte, $tag = 'a') { |
|
| 2519 | if (is_array($texte)) { |
|
| 2520 | array_walk( |
|
| 2521 | $texte, |
|
| 2522 | function(&$a, $key, $t){ |
|
| 2523 | $a = extraire_balises($a, $t); |
|
| 2524 | }, |
|
| 2525 | $tag |
|
| 2526 | ); |
|
| 2527 | ||
| 2528 | return $texte; |
|
| 2529 | } |
|
| 2530 | ||
| 2531 | if (preg_match_all( |
|
| 2532 | ",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS", |
|
| 2533 | $texte, $regs, PREG_PATTERN_ORDER)) { |
|
| 2534 | return $regs[0]; |
|
| 2535 | } else { |
|
| 2536 | return array(); |
|
| 2537 | } |
|
| 2538 | } |
|
| 2539 | ||
| 2540 | /** |
|
| 2541 | * Indique si le premier argument est contenu dans le second |
|