[TriLUG] new PHP question - what's up with join()?

David Rasch rasch at raschnet.com
Tue Jan 25 10:39:06 EST 2005


join takes an array as the second parameter:

$fullName = join(' ', array($firstname, $lastname));
echo "$fullName<br>";

note that perl will only pass to a function an array of scalars, while
php can actually take a set of parameters including arrays, objects, and
scalars.  

David


On Tue, Jan 25, 2005 at 10:35:48AM -0500, Greg Brown <gregbrown at mindspring.com> wrote:
> PHP documentation shows there is a join() function that should, at 
> least in appearance work a lot like Perl's join.  So, I have two 
> variables I want to join $firstName and $lastName.  The following 
> appears like it should work:
> 
> $fullName=join(' ',$firstName,$lastName);
> echo "$fullName<br>";
> 
> $fullName does not appear to be populated, or at least it will not 
> print.  The reason I want to join the variable is I have to have a full 
> name in a database field such as:
> 
> $query="insert into address (firstName,fullName) 
> values('$firstName','$fullName')";
> 
> Is there a better way to do this other then using join?
> 
> Greg
> 
> -- 
> TriLUG mailing list        : http://www.trilug.org/mailman/listinfo/trilug
> TriLUG Organizational FAQ  : http://trilug.org/faq/
> TriLUG Member Services FAQ : http://members.trilug.org/services_faq/
> TriLUG PGP Keyring         : http://trilug.org/~chrish/trilug.asc
> 



More information about the TriLUG mailing list