Page 1 of 1

really simple question.

Posted: Fri Feb 10, 2006 12:54 pm
by mattyboi
Hey guys,

I am embarressed to even ask this question.

I am trying to combine a varible with the value of '1' with the letter 'a' and assigning it to a new varible.

Code: Select all

<?php
$i = 1;
$check = "$i'a'";
echo("$check");
?>
The output should be "1a".

Thanks

Posted: Fri Feb 10, 2006 12:56 pm
by feyd

Code: Select all

<?php
$i = 1;
$check = $i . 'a';
echo($check);
?>

Posted: Fri Feb 10, 2006 9:56 pm
by Ambush Commander
Alternatively:

Code: Select all

$check = "{$i}a";
See string interpolation.

Posted: Sat Feb 11, 2006 12:48 pm
by No0b
The

Code: Select all

.
in fayds post means it's concatenating your $i var with the string "a". Concatenating means to on to. For example:

Code: Select all

$results = "$i";

//then concatenate the var

$results .= "a"
the .= is concatenating the var $results with a new string. This is useful when you want to keep a value of a var and add to it.