How can I capitalize only the first letter in a sentence?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Antonio
    Too lazy to set a custom title
    • Oct 2001
    • 14136

    #1

    How can I capitalize only the first letter in a sentence?

    I have some text that goes like this:


    whatever goes here
    whatever goes here too
    etc

    and I want to make it look like this:
    Whatever goes here
    Whatever goes here too


    Any ideas?
  • mortenb
    Confirmed User
    • Jul 2004
    • 2203

    #2
    php

    put the text in a .txt file with one sentence on each line

    <?php

    $data = file("filename.txt");

    for($i=0;$i<count($data);$i++) {
    echo UCFirst($data[$i])."<br>\n";
    }

    ?>

    Comment

    • Bro Media - BANNED FOR LIFE
      MOBILE PORN: IMOBILEPORN
      • Jan 2004
      • 16502

      #3
      edit:

      or how explained above ;)

      Comment

      • celebx
        Confirmed User
        • Jul 2001
        • 197

        #4
        <?php
        $paragraphs = explode("\n", $text);
        $new_paragraphs = array();
        foreach ($paragraphs as $paragraph => $text) {
        $ln=0;
        while ($text{$ln} || $text{$ln}hahahaha' ' || $text{$ln}hahahaha0) {
        if ($lnhahahaha0) {$new_paragraphs[$paragraph]=strtoupper($text{$ln});}
        else {$new_paragraphs[$paragraph].=$text{$ln};}
        }
        $text='';
        foreach ($new_paragraphs as $paragraph => $text) {
        $text.=$text."\n";
        }
        ?>
        Message me for more info: ICQ 8322641 (@gmail.com).

        Comment

        • Antonio
          Too lazy to set a custom title
          • Oct 2001
          • 14136

          #5
          thanks, I'll give a try in a sec

          Comment

          • celebx
            Confirmed User
            • Jul 2001
            • 197

            #6
            hahahaha is 2x =
            Message me for more info: ICQ 8322641 (@gmail.com).

            Comment

            • Antonio
              Too lazy to set a custom title
              • Oct 2001
              • 14136

              #7
              hmmmm

              what is the 'hahahaha' ?

              Comment

              • Antonio
                Too lazy to set a custom title
                • Oct 2001
                • 14136

                #8
                lo you beat me to it
                thanks ;)

                Comment

                • Antonio
                  Too lazy to set a custom title
                  • Oct 2001
                  • 14136

                  #9
                  Originally posted by mortenb
                  php

                  put the text in a .txt file with one sentence on each line

                  <?php

                  $data = file("filename.txt");

                  for($i=0;$i<count($data);$i++) {
                  echo UCFirst($data[$i])."<br>\n";
                  }

                  ?>
                  It works,
                  Thanks again

                  Comment

                  • mortenb
                    Confirmed User
                    • Jul 2004
                    • 2203

                    #10
                    no problem

                    Comment

                    Working...