PHP Classes

Name String Order: Get person name and surname from a string

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 50%Total: 238 All time: 8,054 This week: 48Up
Version License PHP version Categories
name-string-order 1.0.11Custom (specified...5PHP 5, Text processing, Artificial in...
Description 

Author

This class can get person name and surname from a string.

It can take a string with the name of a person and attempts to detect the actual name by the right order.

The class can return the person first name, last name, or the complete name first with the first name or the last name.

Innovation Award
PHP Programming Innovation award nominee
April 2017
Number 7
The name of a person can be represented in different ways in different places. Sometimes the surname appears first, others times it appears last.

This class can take a look at a string with a person name and detect if the surname comes first or last. Then it can reformat the name according to whatever order is preferred in your PHP application.

Manuel Lemos
Picture of Peter Kahl
  Performance   Level  
Name: Peter Kahl <contact>
Classes: 37 packages by
Country: United Kingdom
Age: ???
All time rank: 41521 in United Kingdom
Week rank: 18 Up2 in United Kingdom Up
Innovation award
Innovation award
Nominee: 23x

Winner: 2x

Documentation

Name String Order

Attempts to order a person's name as 'First Last', 'First Middle Last', 'Last First', and extracts 'First', 'Last' and 'Middle'.

Usage

Romanized Chinese name:

use peterkahl\nameStringOrder\nameStringOrder;

$nameObj = new nameStringOrder('WANG jing-jing');

echo $nameObj->getFirstLast(); # Jing-Jing Wang

echo $nameObj->getLastFirst(); # Wang Jing-Jing

echo $nameObj->getFirst();     # Jing-Jing

echo $nameObj->getLast();      # Wang

Russian name:

use peterkahl\nameStringOrder\nameStringOrder;

$nameObj = new nameStringOrder('???????? ???????????? ?????');

echo $nameObj->getFirstLast();       # ???????? ?????

echo $nameObj->getLastFirst();       # ????? ????????

echo $nameObj->getFirstMiddleLast(); # ???????? ???????????? ?????

echo $nameObj->getFirst();           # ????????

echo $nameObj->getMiddle();          # ????????????

echo $nameObj->getLast();            # ?????

Chinese name:

use peterkahl\nameStringOrder\nameStringOrder;

$nameObj = new nameStringOrder('???');

echo $nameObj->getFirst();     # ??

echo $nameObj->getLast();      # ?

Latin character name:

use peterkahl\nameStringOrder\nameStringOrder;

$nameObj = new nameStringOrder('Curie Marie');

echo $nameObj->getFirstLast(); # Marie Curie

echo $nameObj->getLastFirst(); # Curie Marie

echo $nameObj->getFirst();     # Marie

echo $nameObj->getLast();      # Curie

  Files folder image Files (5)  
File Role Description
Files folder imagesrc (2 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (5)  /  src  
File Role Description
  Accessible without login Plain text file dictionary-first-names.php Aux. Auxiliary script
  Plain text file nameStringOrder.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:238
This week:0
All time:8,054
This week:48Up
User Ratings User Comments (1)
 All time
Utility:70%StarStarStarStar
Consistency:80%StarStarStarStarStar
Documentation:75%StarStarStarStar
Examples:-
Tests:-
Videos:-
Overall:50%StarStarStar
Rank:2687
 
It wont work if its an Indian name
7 years ago (Vivek moyal)
25%StarStar