Simple Question

Posted by: Dignan

Simple Question - 05/05/2003 15:24

I can't gleam this from the PHP manual. How do I combine strings?
Say I have these strings:
$namelast = "Doe"
$namefirst = "John"

and I want to combine them into a string like $name

I don't need for there to be a space, just a result like "DoeJohn"

How do I do that?
Posted by: trs24

Re: Simple Question - 05/05/2003 15:34

I believe you'd do it with a "." like this:

$name = $namelast . $namefirst;

or with a comma and a space:

$name = $namelast . ", " . $namefirst;

EDIT: Forgot my damn semi-colons. always do that.
Posted by: cushman

Re: Simple Question - 05/05/2003 15:41

or you can format them within another string:

$newname = "$namelast$namefirst";

or

$newname = "$namelast, $namefirst";
Posted by: Dignan

Re: Simple Question - 05/05/2003 17:13

Thanks guys. I'm still brushing up on my basics. I just needed this for a particular application. Thanks again!
Posted by: JBjorgen

Re: Simple Question - 05/05/2003 19:00

How do I combine strings


In case you want to impress your programmer friends...they'll expect you to ask "How do I concatenate strings?" In case you're still looking, here's the applicable page from the manual.