As part of a query result, a column with names is returned. I want to apply a function so that the order of first and last name is flipped in my $db results. What is the most efficient way to accomplish this?
There answer probably lies in using either the foreach function, array_walk or array_map but I don't know the proper syntax.
This function does the name flip:
$name = "Lastname, Firstname";
$names = explode(", ", $name);
$name = $names[1] . " " . $names[0];
The $query is similar to this:
$query0="SELECT #__1pgndata.White, #__1pgndata.Black, #__1pgndata.ECO, #__1pgndata.Result, #__1pgndata.EventDate, #__1pgndata.Id
FROM `#__1pgndata` Where #__1pgndata.Id > 155 LIMIT 30"
White and Black are columns for player names (need to be flipped) and correspond to the color of chess pieces. The columns in question are $ginfo->White and $ginfo->Black.