SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I need to transform "New Yor k" into "newyork"

    The following code draws the names of states from my database:

    PHP Code:
    <?php print $r['Area']; ?>
    It prints them out the way you'd ordinarily write them, like Alaska and West Virginia.

    But I need to modify it so that all the letters are lowercase, and there are no spaces, like this:

    newyork
    westvirginia

    Can someone show me how to do this? I have some similar scripts that do that, but I can't get the syntax right on this one. Thanks.

  2. #2
    With More ! for your $ maxor's Avatar
    Join Date
    Feb 2004
    Location
    Scottsdale, Arizona
    Posts
    909
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well this is the wrong forum but...

    PHP Code:
    <?php

    // If $r['Area'] is "New York"

    print strtolower(str_replace(' ','',$r['Area']));

    // Results in newyork
    ?>

  3. #3
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,556
    Mentioned
    183 Post(s)
    Tagged
    6 Thread(s)
    Hi,

    You can transform the text to lowercase with css:
    Code:
    text-transform: lowercase;
    But you can't get rid of the spaces so you may as well stick with maxors solution anyway

    Paul

  4. #4
    With More ! for your $ maxor's Avatar
    Join Date
    Feb 2004
    Location
    Scottsdale, Arizona
    Posts
    909
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is text-transform supported in all browsers/platforms?

  5. #5
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,556
    Mentioned
    183 Post(s)
    Tagged
    6 Thread(s)
    Is text-transform supported in all browsers/platforms?
    Yes right down to NN4.7 I believe

    Paul


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
  •