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

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.

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.