| @@ 2374-2392 (lines=19) @@ | ||
| 2371 | * - Code html de la balise, sinon rien |
|
| 2372 | * - Tableau de résultats, si tableau en entrée. |
|
| 2373 | **/ |
|
| 2374 | function extraire_balise($texte, $tag = 'a') { |
|
| 2375 | if (is_array($texte)) { |
|
| 2376 | array_walk( |
|
| 2377 | $texte, |
|
| 2378 | function(&$a, $key, $t){ |
|
| 2379 | $a = extraire_balise($a, $t); |
|
| 2380 | }, |
|
| 2381 | $tag |
|
| 2382 | ); |
|
| 2383 | ||
| 2384 | return $texte; |
|
| 2385 | } |
|
| 2386 | ||
| 2387 | if (preg_match( |
|
| 2388 | ",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS", |
|
| 2389 | $texte, $regs)) { |
|
| 2390 | return $regs[0]; |
|
| 2391 | } |
|
| 2392 | } |
|
| 2393 | ||
| 2394 | /** |
|
| 2395 | * Extrait toutes les balises html du type demandé |
|
| @@ 2418-2438 (lines=21) @@ | ||
| 2415 | * - Liste des codes html des occurrences de la balise, sinon tableau vide |
|
| 2416 | * - Tableau de résultats, si tableau en entrée. |
|
| 2417 | **/ |
|
| 2418 | function extraire_balises($texte, $tag = 'a') { |
|
| 2419 | if (is_array($texte)) { |
|
| 2420 | array_walk( |
|
| 2421 | $texte, |
|
| 2422 | function(&$a, $key, $t){ |
|
| 2423 | $a = extraire_balises($a, $t); |
|
| 2424 | }, |
|
| 2425 | $tag |
|
| 2426 | ); |
|
| 2427 | ||
| 2428 | return $texte; |
|
| 2429 | } |
|
| 2430 | ||
| 2431 | if (preg_match_all( |
|
| 2432 | ",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS", |
|
| 2433 | $texte, $regs, PREG_PATTERN_ORDER)) { |
|
| 2434 | return $regs[0]; |
|
| 2435 | } else { |
|
| 2436 | return array(); |
|
| 2437 | } |
|
| 2438 | } |
|
| 2439 | ||
| 2440 | /** |
|
| 2441 | * Indique si le premier argument est contenu dans le second |
|