Jump to content

filter_var adds crap to my string


devknob

Recommended Posts

function Clean_String($string)
{
return strtolower(trim(filter_var($string, FILTER_SANITIZE_STRING, FILTER_FLAG_ENCODE_LOW)));
}

 

Ive tracked my issue back to filter_var here. For some reason it is adding stuff to the beginning and end of the string im looking for. It did this on 1 string that I noticed and doesnt do it on any others, which was strange because that string was typical like all others. Just a few sentences and numbers and line breaks.

 

I cant find a reason why this is happening

Link to comment
https://forums.phpfreaks.com/topic/211895-filter_var-adds-crap-to-my-string/
Share on other sites

It looked like it took ...random words from 2 other posts and put 1 before my string and 1 after. It was words and numbers.

 

I went thru and debugged and got back to the filter_var. The string I am passing to Clean_String() absolutely does not contain this extra 'crap' - and I only get extra 'crap' when i leave filter_var in there.

...the thing im scraping has posts posted and taken down all the time and the post is gona. like i said it worked fine until that post, which didnt have strange characters in it.

 

This code works, ill replace my existing code and monitor for errors i guess lol. Guess I was also looking for an understanding of why Filter_Var would/could do something like this. I did not see anything in the documentation./

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.