Code Duplication    Length = 19-21 lines in 2 locations

ecrire/inc/filtres.php 2 locations

@@ 2459-2477 (lines=19) @@
2456
 *     - Code html de la balise, sinon rien
2457
 *     - Tableau de résultats, si tableau en entrée.
2458
 **/
2459
function extraire_balise($texte, $tag = 'a') {
2460
	if (is_array($texte)) {
2461
		array_walk(
2462
			$texte,
2463
			function(&$a, $key, $t){
2464
				$a = extraire_balise($a, $t);
2465
			},
2466
			$tag
2467
		);
2468
2469
		return $texte;
2470
	}
2471
2472
	if (preg_match(
2473
		",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS",
2474
		$texte, $regs)) {
2475
		return $regs[0];
2476
	}
2477
}
2478
2479
/**
2480
 * Extrait toutes les balises html du type demandé
@@ 2503-2523 (lines=21) @@
2500
 *     - Liste des codes html des occurrences de la balise, sinon tableau vide
2501
 *     - Tableau de résultats, si tableau en entrée.
2502
 **/
2503
function extraire_balises($texte, $tag = 'a') {
2504
	if (is_array($texte)) {
2505
		array_walk(
2506
			$texte,
2507
			function(&$a, $key, $t){
2508
				$a = extraire_balises($a, $t);
2509
			},
2510
			$tag
2511
		);
2512
2513
		return $texte;
2514
	}
2515
2516
	if (preg_match_all(
2517
		",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS",
2518
		$texte, $regs, PREG_PATTERN_ORDER)) {
2519
		return $regs[0];
2520
	} else {
2521
		return array();
2522
	}
2523
}
2524
2525
/**
2526
 * Indique si le premier argument est contenu dans le second