Php and MySQL: Dissect fullname string into first, middle and last name and stored it in variables

Discussion in 'PHP' started by nes_jr429, Apr 1, 2013.

  1. #1
    Hello everyone, is there a way that I can dissect a person full name, that is pulled from mysql database, into first name, middle name and last name and stored it into php variables? thanks.. :)
     
    nes_jr429, Apr 1, 2013 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #2
    use php explode to extract names by splitting on spaces?

    explode(" ", "first middle last") but remember there are alot of ppl that have more then one name...
     
    EricBruggema, Apr 1, 2013 IP
  3. nes_jr429

    nes_jr429 Member

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    31
    #3
    thanks for your reply, yeah that is exactly my problem, I have employee column with almost 500 records and most of the names have two strings in first name and also two strings in last name..
     
    nes_jr429, Apr 2, 2013 IP
  4. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #4
    Then that's a problem. But 500 records? can't you do this little job by hand?
     
    EricBruggema, Apr 2, 2013 IP
  5. nes_jr429

    nes_jr429 Member

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    31
    #5
    yeah actually I tried some solution here, but this was a bit painful, I just manually editted it using excel, I used text to column tool and manually fix the names, and that's it, a last option painful solution... :( ... hehe anyway thanks for your reply.. :)
     
    nes_jr429, Apr 3, 2013 IP