You are here:  » Strip X number of characters filter


Strip X number of characters filter

Submitted by noodles on Sun, 2006-11-05 19:04 in

David,

Would it be a big job to write a filter to strip x number of characters from the front of a field? If it is don't worry about it.

Thanks
Dave

Submitted by support on Sun, 2006-11-05 19:31

Hi Dave,

Have a go with this;

<?php
  
/*************************************************/
  /* stripX                                        */
  /*************************************************/
  
$filter_names["stripX"] = "Strip X";
  function 
filter_stripXConfigure($filter_data)
  {
    print 
"Number of characters to strip:<br />";
    print 
"<input type='text' name='num' value='".widget_safe($filter_data["num"])."' />";
    
widget_errorGet("num");
  }
  function 
filter_stripXValidate($filter_data)
  {
    if (!
intval($filter_data["num"]))
    {
      
widget_errorSet("num","number required");
    }
  }
  function 
filter_stripXExec($filter_data,$text)
  {
    return 
substr($text,intval($filter_data["num"]));
  }
?>

Cheers,
David.

Submitted by noodles on Sun, 2006-11-05 19:44

That's perfect, many thanks for your help.

David