Thread: HTML Filter
View Single Post
  #1  
Old 09-16-2013, 12:38 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
HTML Filter

I wrote a function that removes all HTML from a string.

PHP Code:
function onCreated()
  
filterHTML("Hi my name is definitely not <b>dylan</b> and I <a href=http//google.com/>may or may</a> not be slightly insane.<br>");

function 
filterHTML(temp.text)
{
  echo(
"Unfiltered:" SPC temp.text);
  
  do {
    
temp.htmlStart temp.text.pos("<");
    
temp.htmlEnd   temp.text.pos(">");
    
    
temp.text  temp.text.substring(0temp.htmlStart) @ temp.text.substring(temp.htmlEnd 1);
  } while (
temp.text.pos("<") > -1);
  
  echo(
"Filtered:" SPC temp.text);

  return 
temp.text;

PHP Code:
UnfilteredHi my name is definitely not <b>dylan</b> and <a href=http//google.com/>may or may</a> not be slightly insane.<br>
FilteredHi my name is definitely not dylan and I may or may not be slightly insane
Enjoy!
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote