I have a full name passed to my webpage in the format 'lastname, firstname'.

So if $a = 'Doe, John'
what could I do to parse this field out using the comma as a delimiter, and end up with $b containing 'John' and $c containing 'Doe'.

I would appreciate any ideas on how to do this. Thanks.

Recommended Answers

All 2 Replies

$x = split(",", $a);
$fname = trim($x[1]);
$lname = trim($x[0]);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.