We help IT Professionals succeed at work.

&amp in PHP strings

soffcec
soffcec used Ask the Experts™
on
How can I add & (&amp) to PHP string ?

I am trying to put string like "a=somstuff&b=morestuff" together
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
You mean like this
<?php
$var = "a=somstuff&b=morestuff";
echo($var);
?>

Open in new window

soffcecManager

Author

Commented:
I am using text variable

$a = "somestuff" and $b="morestuff"

How will that syntax look ?
You mean you want to combine $a = "somestuff" and $b="morestuff" with character & in the middle?

Is it like

$a = "somestuff";
$b="morestuff";
$ab = $a."&".$b;

or

$text = '$a="somestuff"&$b="morestuff" ';
soffcecManager

Author

Commented:
It's getting better, but when I try to parse the result of $ab I only get  the data from $a not what comes after &
If I do like this

$a = "somestuff";
$b="morestuff";
$ab = $a."&".$b;
echo($ab);

it will display:

somestuff&morestuff

is it what you want?


or is it like

$a = "a=somestuff";
$b="b=morestuff";
$ab = $a."&".$b;
echo($ab);

you will get

a=somestuff&b=morestuff