Bootstrap FreeKB - PHP - Append values to a variable using .=
PHP - Append values to a variable using .=

Updated:   |  PHP articles

Let's say you have a variable that contains fruit.

$fruit = "banana apple orange grape";

 

The .= operator can be used to append values to the end of the variable. In this example, pineapple will be appended to the $fruit variable.

$fruit .= "pineapple";

 

The variable can be printed.

echo $fruit;

 

The original values in the variable plus pineapple will be printed.

banana apple orange grape pineapple

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter c5cda1 in the box below so that we can be sure you are a human.