Code Duplication    Length = 19-21 lines in 2 locations

ecrire/inc/filtres.php 2 locations

@@ 2510-2528 (lines=19) @@
2507
 *     - Code html de la balise, sinon rien
2508
 *     - Tableau de résultats, si tableau en entrée.
2509
 **/
2510
function extraire_balise($texte, $tag = 'a') {
2511
	if (is_array($texte)) {
2512
		array_walk(
2513
			$texte,
2514
			function(&$a, $key, $t){
2515
				$a = extraire_balise($a, $t);
2516
			},
2517
			$tag
2518
		);
2519
2520
		return $texte;
2521
	}
2522
2523
	if (preg_match(
2524
		",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS",
2525
		$texte, $regs)) {
2526
		return $regs[0];
2527
	}
2528
}
2529
2530
/**
2531
 * Extrait toutes les balises html du type demandé
@@ 2554-2574 (lines=21) @@
2551
 *     - Liste des codes html des occurrences de la balise, sinon tableau vide
2552
 *     - Tableau de résultats, si tableau en entrée.
2553
 **/
2554
function extraire_balises($texte, $tag = 'a') {
2555
	if (is_array($texte)) {
2556
		array_walk(
2557
			$texte,
2558
			function(&$a, $key, $t){
2559
				$a = extraire_balises($a, $t);
2560
			},
2561
			$tag
2562
		);
2563
2564
		return $texte;
2565
	}
2566
2567
	if (preg_match_all(
2568
		",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS",
2569
		$texte, $regs, PREG_PATTERN_ORDER)) {
2570
		return $regs[0];
2571
	} else {
2572
		return array();
2573
	}
2574
}
2575
2576
/**
2577
 * Indique si le premier argument est contenu dans le second