Jump to content

[SOLVED] Really simple, how to display a variable then delimiter then variable


jaxdevil

Recommended Posts

I know this one I just can't remember it. How do I make this:

 

$FinalCat = '$SubSubCat|$SubSubSubCat';

 

Display the actual variable with a | and then the other variable.

 

I.e. if the variable $SubSubCat means 'hello' and $SubSubSubCat means 'goodbye' then I want to make $FinalCat mean 'hello|goodbye'

 

How do I accomplish this?

 

Thanks in advance guys!

 

SK

Link to comment
Share on other sites

Couple of different approaches:

 

echo $foo.'|'.$bar;
//or:
echo "$foo|$bar";

 

Basically, variables inside single quotes are not parsed. That is, if you echo this:

 

echo '$var';

 

Then all that will be displayed is $var. However, they are parsed (and therefore their value is displayed) if inside double quotes. So you either place them inside double quotes or use no quotes at all and concatenate.

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.