>> 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 <option> tags):

foreach ($name_array as $person) {
    $lastname_element = count($person) - 1; //index of last element
    echo "<option>" . $person[$lastname_element] . ", ";
    echo $person[0] . "</option>\n"; //zero (0) is the first name
}


Ben Ramsey wrote:


This works rather nicely, too:

<?php
$list = "Firstname1 LastName1
Firstname2 Lastname2";

$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 show you the values.


-- Regards, Ben Ramsey http://benramsey.com http://www.phpcommunity.org/wiki/People/BenRamsey

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to