Remove Shouting


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function RemoveShouting($string)
  2. {
  3. $lower_exceptions = array(
  4. "to" => "1", "a" => "1", "the" => "1", "of" => "1"
  5. );
  6.  
  7. $higher_exceptions = array(
  8. "I" => "1", "II" => "1", "III" => "1", "IV" => "1",
  9. "V" => "1", "VI" => "1", "VII" => "1", "VIII" => "1",
  10. "XI" => "1", "X" => "1", "GAs"=>'1'
  11. );
  12.  
  13. $words = split(" ", $string);
  14. $newwords = array();
  15. foreach ($words as $word)
  16. {
  17. if (!$higher_exceptions[$word]) $word = strtolower($word);
  18. if (!$lower_exceptions[$word]) $word[0] = strtoupper($word[0]);
  19. array_push($newwords, $word);
  20. }
  21. return join(" ", $newwords);
  22. }

URL: http://www.subeta.org

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.