Code Duplication    Length = 19-21 lines in 2 locations

ecrire/inc/filtres.php 2 locations

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