$replacement = array ('&' => '&', '<' => '<', '>' => '>', '"' => '"'); /* * Given a $matches from a successful match in which $matches[0] is the text character in need of * conversion to HTML, return the appropriate HTML string. Because this function is used under only * carefully controlled conditions, we feel safe blindly using the arguments. */ function text2html_callback($matches) { global $replacement; return $replacement[$matches[0]]; } $new_subject = preg_replace_callback('/[&<">]/S', /* pattern */ "text2html_callback",/* callback */ $subject); ----------------------------------------------------------------------------- Copyright 1997-2024 Jeffrey Friedl