![]() |
Name splitter library? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11) +--- Thread: Name splitter library? (/showthread.php?tid=71391) |
Name splitter library? - kaitenz - 08-09-2018 Hello people! I just want to know if there's an existing PHP library file (for CodeIgniter or maybe a vanilla PHP) that splits a full name into parts: i.e: Bond, James E. returns PHP Code: array( I found this library called PHP Name Parser (https://github.com/joshfraser/PHP-Name-Parser), but it doesn't fit to my requirements. It actually works but the "LastName, FirstName MiddleName" pattern don't work with the library. Thanks in advance.. Hope someone can help me. RE: Name splitter library? - Pertti - 08-09-2018 This one seems quite complete and handles middle names https://github.com/theiconic/name-parser Haven't used it myself. RE: Name splitter library? - kaitenz - 08-09-2018 The tool is great. But we have a problem. I test the library with this name: "John James E. Bond". The result returns like this: PHP Code: array( I've already installed that to my project via Composer. RE: Name splitter library? - Pertti - 08-10-2018 (08-09-2018, 08:56 PM)kaitenz Wrote: The result returns like this: What would you like it to return as? RE: Name splitter library? - kaitenz - 08-10-2018 (08-10-2018, 12:59 AM)Pertti Wrote:(08-09-2018, 08:56 PM)kaitenz Wrote: The result returns like this: The ['firstName'] should return as "John James". The ['middleName'] should return "E." and ['lastName'] should return "Bond". RE: Name splitter library? - John_Betong - 08-10-2018 @kaitenz example 001: Bond, James E. example 002: John James E. Bond" First example has surname first and second example has surname last! Reminds me of: https://en.wikipedia.org/wiki/Garbage_in,_garbage_out It would help if there was a full list of possible names. PHP Code: echo '', $str = "John James E. Bond"; Output: Quote:John James E. Bond |