View Single Post
Old 01-09-2008, 05:01 AM  
SmokeyTheBear
►SouthOfHeaven
 
SmokeyTheBear's Avatar
 
Join Date: Jun 2004
Location: PlanetEarth MyBoardRank: GerbilMaster My-Penis-Size: extralarge MyWeapon: Computer
Posts: 28,609
Code:
<?php
function custom_ucwords($map, $string) {

   $inside_word = TRUE;

   for ($index = 0; $index < strlen($string); ++$index) {


      $is_chr = isset($map[$string[$index]]);


      if (! $inside_word && $is_chr) {
          $string[$index] = $map[$string[$index]];
      }

      $inside_word = $is_chr;
   }

   return $string;
}


$map = array(
   'a' => 'A', 'b' => 'B', 'c' => 'C', 'd' => 'D',
   'e' => 'E', 'f' => 'F', 'g' => 'G', 'h' => 'H',
   'i' => 'I', 'j' => 'J', 'k' => 'K', 'l' => 'L',
   'm' => 'M', 'n' => 'N', 'o' => 'O', 'p' => 'P',
   'q' => 'Q', 'r' => 'R', 's' => 'S', 't' => 'T',
   'u' => 'U', 'v' => 'V', 'w' => 'W', 'x' => 'X',
   'y' => 'Y', 'z' => 'Z'
);

$string = file_get_contents("file.txt");
echo custom_ucwords($map, $string);
?>
save as do.php

put words in a file called file.txt

visit php ina browser
__________________
hatisblack at yahoo.com
SmokeyTheBear is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote