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
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.

Link to comment
Share on other sites

...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./

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.