Code Duplication    Length = 19-21 lines in 2 locations

ecrire/inc/filtres.php 2 locations

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