Aug 02, 2021
Today i will explained How to Concatenate String, Variable and Arrays in php 8 and other versions. THis articalis also working with php.
The concatenate term in PHP refers to joining multiple strings into one string; it also joins variables as well as the arrays.PHP, concatenation is done by using the concatenation operator (".") which is a dot.
Php is provided to the two types of Concatenation ("."),('.=') to provided in php 8.
So let's start to the artical.
The dot concatenation operator in PHP concatenate its right and left arguments.
This second concatenation operator helps in appending the right side argument to the left side argument.
Concatenate Two Strings & Variables In PHP Example
$string1 = 'John';
$string2 = 'shina';
$name_str = $string1 . ' ' . $string2;
Concatenating Variable With String In PHP Example
$var = "Hello";
echo $var.' World';
Concatenate Two Arrays In PHP Example
This example to learn how to merge two array in php using array_merge() method through.
$myArr = array(1, "tv" => "ac", 2, "washing machine", 3);
$mySecondArr = array("word", "abc", "vegetable" => "tomato", "state" => "washington dc");
$output = array_merge($myArr, $mySecondArr);
 => 1
[tv] => ac
 => 2
 => washing machine
 => 3
 => word
 => abc
[vegetable] => tomato
[state] => washington dc
Now you can check your own.
I hope it can help you...