Hello great computer chiefs! I'm using this code to remove links from an output page: function _replacement($text) { $array = array("A HREF" => " ", "a href" => " ", "<form>" => " ", "</form>" => " "); foreach($array as $original => $replacement) { $text = str_replace($original, $replacement, $text); } return $text; } I would like develop this code to remove all html and Javascript, so that only text is output (the text of an atricle). Any suggestions on how to do this? Thanks Luke.
First off, str_replace can take arrays as arguments, so you could do: function _replacement($text) { $array = array("A HREF" => " ", "a href" => " ", "<form>" => " ", "</form>" => " "); return str_replace(array_keys($array), array_values($array), $text); } PHP: And besides that, have a look at www.php.net/strip_tags
Hello Nico, Yes, strip_tags would be the best thing, but as I mentioned on this thread, I can't get both the strip_tags and str_replace to work together. It's either one or the other. I'm not very experienced with php.
Before you ask again what a function is for, or what it does, you have to bookmark following page: www.php.net From now on, this page is your new best friend. Type "htmlentities" in the search field and hit enter. The answer to your question lays there. And do the same in the future, when you come across functions you don't know.