Your Ad Here

Posted By

vanity on 12/08/06


Tagged

php String shouting


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

willcodeforfood


Remove Shouting


 / Published in: PHP
 

URL: http://www.subeta.org

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

Report this snippet  

You need to login to post a comment.