Home » PHP Code »

1

The following script will be clean a string, this code fill helpful when going send a string to url that means using get method using php.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function CleaningAString($string)
  {
      $string = strtolower($string);
      // Replace other special chars
      $specialCharacters = array(
     '#' => 'sharp',
     '$' => 'dollar',
     '%' => 'percent',
     '&' => 'and',
     '@' => 'at',
     '€' => 'euro',
     '+' => 'plus',
     '=' => 'equals to',
     '§' => 'paragraph',
      );
     while (list($character, $replacement) = each($specialCharacters))  {
          $string = str_replace($character, '-' . $replacement . '-', $string);
      }
      return $string;
  }

This code will replace the all special characters to string using following this php function.

I hope that it will be helpful.


Related Posts

    How to create excel file with mysql data using php codeHow to add line breaks in the textareaHow to convert feeds to html using javascript and phpSEO - URL using php code and .htaccess

 

1 Comment

Leave a Reply