We help IT Professionals succeed at work.

Parsing data

John Account
John Account asked
on
Medium Priority
189 Views
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 :
johnlucio

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?
Comment
Watch Question

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

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

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

Commented:

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

Open in new window

Commented:
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.