Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   HTML Filter (https://forums.graalonline.com/forums/showthread.php?t=134268740)

xXziroXx 09-16-2013 12:38 AM

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!


All times are GMT +2. The time now is 12:39 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.