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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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";

Link to comment
Share on other sites

yeah, as old car points out..basically gareth you were cancatenating your variables incorrectly which lead to you having one too many double quotations...there are several ways to concatenate, really up to personal choice..

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.