| @@ 2312-2330 (lines=19) @@ | ||
| 2309 | * - Code html de la balise, sinon rien |
|
| 2310 | * - Tableau de résultats, si tableau en entrée. |
|
| 2311 | **/ |
|
| 2312 | function extraire_balise($texte, $tag = 'a') { |
|
| 2313 | if (is_array($texte)) { |
|
| 2314 | array_walk( |
|
| 2315 | $texte, |
|
| 2316 | function(&$a, $key, $t){ |
|
| 2317 | $a = extraire_balise($a, $t); |
|
| 2318 | }, |
|
| 2319 | $tag |
|
| 2320 | ); |
|
| 2321 | ||
| 2322 | return $texte; |
|
| 2323 | } |
|
| 2324 | ||
| 2325 | if (preg_match( |
|
| 2326 | ",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS", |
|
| 2327 | $texte, $regs)) { |
|
| 2328 | return $regs[0]; |
|
| 2329 | } |
|
| 2330 | } |
|
| 2331 | ||
| 2332 | /** |
|
| 2333 | * Extrait toutes les balises html du type demandé |
|
| @@ 2356-2376 (lines=21) @@ | ||
| 2353 | * - Liste des codes html des occurrences de la balise, sinon tableau vide |
|
| 2354 | * - Tableau de résultats, si tableau en entrée. |
|
| 2355 | **/ |
|
| 2356 | function extraire_balises($texte, $tag = 'a') { |
|
| 2357 | if (is_array($texte)) { |
|
| 2358 | array_walk( |
|
| 2359 | $texte, |
|
| 2360 | function(&$a, $key, $t){ |
|
| 2361 | $a = extraire_balises($a, $t); |
|
| 2362 | }, |
|
| 2363 | $tag |
|
| 2364 | ); |
|
| 2365 | ||
| 2366 | return $texte; |
|
| 2367 | } |
|
| 2368 | ||
| 2369 | if (preg_match_all( |
|
| 2370 | ",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS", |
|
| 2371 | $texte, $regs, PREG_PATTERN_ORDER)) { |
|
| 2372 | return $regs[0]; |
|
| 2373 | } else { |
|
| 2374 | return array(); |
|
| 2375 | } |
|
| 2376 | } |
|
| 2377 | ||
| 2378 | /** |
|
| 2379 | * Indique si le premier argument est contenu dans le second |
|