vendredi 17 avril 2015

How can I concatenate a string with variables in PHP?

Here is my simple code logic just for the sake of simplicity. I wanna concatenate string like: 10,11,12,13,14, but it's just adding all the values displaying wrong output as: ,100 it should display like: 10,11,12,13,14 like other programming languages do.



<?php

// list is a string variable
$list="";

//total number of seats in a Bus
$setnum=10;

for($i = 0; $i < 10; $i++) {
//i trying to concatenate string like 10,11,12,13,14
$list="$list".$i+$setnum.', ';
}

echo $list;

?>

Aucun commentaire:

Enregistrer un commentaire