View Full Version : PHP Combining string variables;
If I have two string variables containing data eg. $firstname = Dave and $surname = Bloggs and I want to create a new variable by combining these two eg $name which would contain Dave Bloggs, how do I do this in PHP?
simple
<?
$firstname = "Dave";
$surname = "Bloggs";
$fullname = "$firstname $surname";
print "My name is $fullname.";
/////////
$firstname = "Dave";
$surname = "$firstname Bloggs";
print "My name is $surname.";
?>
Or if you weren't bothered about keeping $firstname,
$firstname = "Dave"; $firstname .= " Bloggs";
Either method would work fine :eek:
Cheers for that. I suspect I will find both methods useful before I finish. :)
you may find Array() very useful for this type of scripting.
vBulletin® v3.7.1, Copyright ©2000-2008, Jelsoft Enterprises Ltd.