-2

I want to make a php variable a group of other variables so that I can put the new group of variables into a .txt file. Something like:

    $txt = $_GET["html"]
    $txt2 = $_GET["js"]
    $txt3 = $_GET["php"]
    $txt4 = $_GET["other"]
    $text = $txt $txt2 $txt3 $txt4;
    $filename = fopen("config.txt", "w");
    fwrite($filename, $text);
    fclose($filename);

I have searched on Google and Stack Overflow, but nothing seems to solve my problem.

Felix
  • 39
  • 7
  • 2
    `.` is for concatenation. RTFM please. – u_mulder Dec 12 '15 at 19:41
  • 1
    You could also wrap in double quotes - `$text = "$txt $txt2 $txt3 $txt4";` in addition to concatenation - `$text = $txt . $txt2 . $txt3 . $txt4;` – Sean Dec 12 '15 at 19:45

1 Answers1

1

If you just want to combine multiple string values into one string value then the term you're looking for is "concatenate", which in PHP is done with the . operator:

$text = $txt . $txt2 . $txt3 . $txt4;
David
  • 208,112
  • 36
  • 198
  • 279