Is there any way where i can filter special characters like
such as
,./<>?;:'"[]{}-!@#$%&*()_+

$Keyword = (isset($_GET['Keyword'])) ? $_GET['Keyword'] : '';
$trimmedKeyword = trim($Keyword);
$trimmedKeyword = stripslashes($trimmedKeyword);
$trimmedKeyword = str_replace('"', '', $trimmedKeyword);
//trim whitespace from the stored variable
$trimmedKeyword = preg_replace('#\s+#',' ',$trimmedKeyword);
$trimmed_arrayKeyword = explode(" ",$trimmedKeyword);

    put them into an array and use [man]str_replace[/man]

      Thanks ..

      Ok i used the array method

      $filter = array("!", "@", "#", "$", "%", "", "&", "", "", "(");
      $trimmedKeyword = str_replace($filter, "", "$trimmedKeyword");

      but i was unable to filter these two characters

      \ and "

      why is it so?

      Another thing is if i were to type Crack !@#$

      how should i display only Crack without !@#$ when i echo the value

      <? echo $keyword; ?>

      $Keyword = (isset($_GET['Keyword'])) ? $_GET['Keyword'] : '';
      $trimmedKeyword = trim($Keyword);
      $trimmedKeyword = stripslashes($trimmedKeyword);
      $trimmedKeyword = str_replace('"', '', $trimmedKeyword);
      //trim whitespace from the stored variable
      $trimmedKeyword = preg_replace('#\s+#',' ',$trimmedKeyword);
      $trimmed_arrayKeyword = explode(" ",$trimmedKeyword);
      

        1) If you look up what the manual says about strings you'll see that " and \ have special meanings. So if you want them to be treated literally, they need to be escaped with \ (that's \'s special meaning). So it's not """ and "\", it's "\"" and "\"

        2) Remove the unwanted characters and then display what's left.

          Write a Reply...