I am completely new to PHP and to prevent from any attack and to store proper values in a variable I am trying to sanitize, trim for spaces and remove any illegal character. I have a variable
$value = "this, <script></script>, 's 18in,";
The above variable consists many unwanted characters like ,
blank space
, <> tags
.
What I want to do is I want to remove all the invalid characters from the string and make it a pure form string with only have alphabets or numbers like
$value = "thiss18in"; <= after sanitization
Can anyone help me with this logic?