Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    May 2009
    Posts
    92
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Help! Getting just letters

    I've been going crazy over this for hours. If I am given a string such as this:

    $variable = "45$^nAm5e#";

    How can I go about pulling ONLY the letters from that variable? In other words, is there a way to make it like this:

    $variable = "nAme";


    ??

    Thanks for any help!

  • #2
    Regular Coder seco's Avatar
    Join Date
    Nov 2008
    Location
    Oregon
    Posts
    687
    Thanks
    6
    Thanked 79 Times in 77 Posts
    PHP Code:
    echo preg_replace("/[^a-zA-Z\s]/"""$variable); 
    Last edited by seco; 09-12-2009 at 10:05 PM.


  •  

    Posting Permissions

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