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
[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 option . $arrayFoo[2] . nbsp; . $arrayFoo[1] . nbsp;
. $arrayFoo[0] . /option;
} else {
echo option . $arrayFoo[1] . nbsp; .
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 option
JO list for a form. But how do I reverse the
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
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;
5 matches
Mail list logo