- Forums
- PHP
- How To Combine Or Merge Two Strings Into One String In Php
This Page Contains information about How To Combine Or Merge Two Strings Into One String In Php By wallpaperama in category PHP with 4 Replies. [1241], Last Updated: Sat May 18, 2024
wallpaperama
Sat Jan 10, 2009
4 Comments
9374 Visits
today i will teach you how you can make two string into one. if you are reading my post here its probably because you are writing a php script and in your code you want to put two strings into one, well, making the two string variables into one variable its very easy with php.
for example, lets say i have these two string:
<?php
$string1 = "free";
$string2 = "wallpapers";
echo $string1;
?>
OUTPUT:
free
now lets say i want to to combine $string1 to have the value of both string, so the goal is to have $string1 equal the value of "freewallpapers" you can do it like this:
<?php
$string1 = "free";
$string2 = "wallpapers";
$string1 = $string1.$string2;
echo $string1;
?>
OUTPUT:
freewallpapers
as you can see we combined the two string into one, but freewallpapers is not a word, we can put a space in between like this:
<?php
$string1 = "free";
$string2 = "wallpapers";
$string1 = $string1.' '.$string2;
echo $string1;
?>
OUTPUT:
free wallpapers
the best way to see it in action is for you to try it, try puthing this code in a php file and run it on your php site.
hope that helps
https://www.wallpaperama.com/forums/how-to-combine-two-strings-into-one-string-in-php-t6977.html