Re: [PHP] Switching First & Last Names in List

2004-03-16 Thread Ben Ramsey
>> JO> so that the last name is first? Also, how do I >> JO> handle people with three names? Thanks. I missed this part, so here's my take with the solution I provided (I'm including the print-out of the tags): foreach ($name_array as $person) { $lastname_element = count($person) - 1; //inde

Re: [PHP] Switching First & Last Names in List

2004-03-16 Thread Ben Ramsey
This works rather nicely, too: $name_array = array(); $temp_array = explode("\n", $list); foreach ($temp_array as $name) { $name_array[] = explode(" ", $name); } print_r($name_array); ?> $name_array is now a multi-dimensional array with the first and last names separated. print_r should

Re: [PHP] Switching First & Last Names in List

2004-03-16 Thread Richard Davey
Hello Jeff, Tuesday, March 16, 2004, 3:24:57 PM, you wrote: JO> If I have a list like this: JO> Firstname1 LastName1 JO> Firstname2 Lastname2 JO> etc. JO> I can split the names by \n to put them into JO> an array which will then be output into an JO> list for a form. But how do I reverse the na

RE: [PHP] Switching First & Last Names in List

2004-03-16 Thread Jay Blanchard
[snip] If I have a list like this: Firstname1 LastName1 Firstname2 Lastname2 etc. [/snip] do the split or explode for each item ... if(3 == count($arrayFoo)){ echo "" . $arrayFoo[2] . " " . $arrayFoo[1] . " " . $arrayFoo[0] . ""; } else { echo "" . $arrayFoo[1] . " " . $arrayFoo[0] . ""; }

Re: [PHP] Switching First & Last Names in List

2004-03-16 Thread Neil Freeman
Take a look at explode() www.php.net/explode Neil Jeff Oien wrote: *** This Email Has Been Virus Swept *** If I have a list like this: Firstname1 LastName1 Firstname2 Lastname2 etc. I can split the names by \