Results 1 to 8 of 8

Thread: Need Help with Capitalization

  1. #1
    Join Date
    Feb 2009
    Posts
    62
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default Need Help with Capitalization

    Ok so my website is Kywordpro.com

    I want the search query to auto capitalize the first letter to make it look more professional in other search engines an on the site.


    Can anyone help with this?

    Tim..

  2. #2
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    If you want the first letter in the string to be capitalized use ucfirst(). If you want to capitalize the first letter of every word use ucwords().

    Good luck!
    Eddy Proca
    I love Dropbox. Get it through my girlfriend's referral link (I reached my limit) and both you and her get 500 MB extra! Thanks and you're welcome!

  3. #3
    Join Date
    Feb 2009
    Posts
    62
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default

    Ok Snookerman you were helpful but I still am confused.

    I am not sure where to put the code since I didnt write the code for my site.

    Tim..

  4. #4
    Join Date
    Apr 2008
    Location
    Limoges, France
    Posts
    395
    Thanks
    13
    Thanked 61 Times in 61 Posts

    Default

    Quote Originally Posted by tgallagher26 View Post
    Ok so my website is Kywordpro.com

    I want the search query to auto capitalize the first letter to make it look more professional in other search engines an on the site.


    Can anyone help with this?

    Tim..
    I don't understand what you are talking about. The first letter of what? As far as I know you can't control how anything looks in other search engines.

  5. #5
    Join Date
    Feb 2009
    Posts
    62
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default

    Ok if you visit my site you will see that whatever you search appears in the TITLE liek this.

    search words :: KyWordPRO.com

    I want it to look like this.

    Search Words :: KywordPRO.com

    Does that make more sence?

    To make this happen the code in place is

    <title><?php echo isset($q) ? ('' . $q) : TITLE; ?> :: KyWordPRO.com</title>

  6. #6
    Join Date
    Apr 2008
    Location
    Limoges, France
    Posts
    395
    Thanks
    13
    Thanked 61 Times in 61 Posts

    Default

    Change it to this:

    <title><?php echo isset($q) ? ('' . ucwords($q)) : TITLE; ?> :: KywordPRO.com</title>

  7. #7
    Join Date
    Feb 2009
    Posts
    62
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default

    Ok so if I wanted to emplement this version

    <?php
    function title_case($title) {
    $smallwordsarray = array(
    'of','a','the','and','an','or','nor','but','is','if','then',
    'else','when',
    'at','from','by','on','off','for','in','out',
    'over','to','into','with'
    );

    $words = explode(' ', $title);
    foreach ($words as $key => $word)
    {
    if ($key == 0 or !in_array($word, $smallwordsarray))
    $words[$key] = $this->my_ucwords(strtolower($word));
    }

    $newtitle = implode(' ', $words);
    return $newtitle;
    }
    ?>

    How would I make it possible?
    Last edited by tgallagher26; 02-23-2009 at 07:58 PM.

  8. #8
    Join Date
    Jan 2008
    Posts
    4,167
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    What do you want to be capitalized? $newtitle?
    PHP Code:
    return $newtitle
    To:
    PHP Code:
    return ucfirst($newtitle); 
    Jeremy | jfein.net

  9. The Following User Says Thank You to Nile For This Useful Post:

    tgallagher26 (03-06-2009)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •