We help IT Professionals succeed at work.

Parsing data

John Account
John Account asked
Medium Priority
Last Modified: 2013-12-12
there is a field in my DB that contains the name of a person in this format : Lucio, John

When this $name variable is returned, it looks like this :
Lucio, John
I need to make a new variable with it that will look like this :

in other words, I need to remove the capital letters, I also need to remove the comma and inverse the first name and last name.

Is that feasable?
Watch Question

$name=strtolower("Lucio, John");

$namearray=explode(", ",$name);

$newname = $namearray[1].$namearray[0];


$x =  'Lucio, John';
$x = explode(',',strtolower($x));
$x = trim($x[1].$x[0]);
echo $x;

Open in new window

Hi JohnLucio, thank you for the points, but for the future, you should share the points between two correct, essentially simultaneous answers.  It's fair and it keeps people from rushing off a fast barely adequate answer just to be first :))

Explore More ContentExplore courses, solutions, and other research materials related to this topic.