black_belt
black_belt

Reputation: 6799

How to Add Text after a PHP variable

I have a variable named "$autovalue" . My another variable called $row1 and I want it to contain the value of "$autovalue" with a "_1" so that when I echo the $row1 it looks like this: 2011_1 (here 2011 is the value of $autovalue and " _1 " is what I want to include). I tried the following method but it is not working.

Could you please tell me how to achieve this ?

Thanks in Advance :)

   $autovalue=mysql_insert_id();

    $row1=$autovalue.""._1;
    $row2=$autovalue.""._2;
    $row3=$autovalue.""._3;
    $row4=$autovalue.""._4;

Upvotes: 1

Views: 14055

Answers (4)

Akbar Soft
Akbar Soft

Reputation: 1066

you can also add texts by this way :

$text = '12';

$text .= '34';
$text .= '56';
$text .= '78';

echo $text;

the result will be : 12345678

Upvotes: 2

Stewie
Stewie

Reputation: 3121

$row1 = $autovalue."_".1;

Upvotes: 1

Matteo B.
Matteo B.

Reputation: 4064

Personally preferred:

$row1 = sprintf( '%s_1', $autovalue );

See the manual's page about sprintf for further information.

Upvotes: 1

Virendra
Virendra

Reputation: 2553

$row1 = $autovalue . "_1";
$row2 = $autovalue . "_2";
$row3 = $autovalue . "_3";
$row4 = $autovalue . "_4";

Upvotes: 4

Related Questions