Code Duplication    Length = 19-21 lines in 2 locations

ecrire/inc/filtres.php 2 locations

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