Remplacement sélectif, hors ou dans balises html : Vos contributions



How to select a text, except html tags? #php See below an efficient php code to do it! The post where is extract this code is in French but it's very interresting: you can see the first version of this code and how to optimize it.




function split_htmtag($de, $par, $txt, $fct, $flag = 1){
  global $arg;
  $arg = compact('de', 'par', 'fct', 'flag');
  return preg_replace_callback('#((?:(?!&lgt;[/a-z]).)*)([^&rgt;]*&rgt;|$)#si', "split_htmtag_callback", $txt);
}
function split_htmtag_callback($capture){
  global $arg;
  return ($arg['flag'] == 1)
  ? $arg['fct']($arg['de'], $arg['par'], $capture[1]).$capture[2]
  : $capture[1].$arg['fct']($arg['de'], $arg['par'], $capture[2]);
}



Next Bookmark: C’est quoi un FabLab ? Tour d’horizon | Zevillage : Télétravail, coworking et nouvelles formes de travail
Previous Bookmark: Une école sans salle de classe ?


Who is behind this blog?

I'm passionate about what I do, and I love to help people


Nothing is more fulfilling than being part of a team with similar interests, and an organization that values its employees


ABOUT ME