Jump to content

Multiple Variables and a Space in a String


GarethB

Recommended Posts

Hi Guys and Girls,

 

Long time lurker, first time poster!

 

I am usually able to read through the forums and find and answer without having to start a new thread but I've tried my best to no avail.

 

I am having trouble with the following code:

$afname="Gareth";
$alname="B";
$awayoption.="<OPTION VALUE=\"".$afname." \"".$alname."\">".$afname." ".$alname;

 

I would want that to produce the following:

 

<OPTION VALUE=Gareth B">Gareth B

 

The actual result at the moment is:

 

<OPTION VALUE="Gareth "B">Gareth B

 

It has an extra " in the middle. Any ides or help would be great!

 

Cheers

Wow thank you - worked a treat. I'm still at a very basic level at this point.

 

Is it a case of you can use {} to define variables then where you are using commas within commas, and this will allow a space in the middle? (Oh my I've just confused myself!)

 

Cheers

or even

 

$afname="Gareth";
$alname="B";
$awayoption.="<OPTION VALUE='$afname $alname'>$afname $alname";

 

can even combine them before like this

 

$afname="Gareth";
$alname="B";
$fullname = "$afname $alname";
$awayoption.="<OPTION VALUE='$fullname'>$fullname";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.