Jump to content

Please help with a string


PunjabHaker

Recommended Posts

Ted's is sweet and to the point. Here is one pretty much the same but stores the loop in a variable.

<?php
$generate = 6;
$line = '';
for($i=1; $i<=$generate; $i++){
$line .= "String$i, "; // add each loop into one variable
}
echo substr($line, 0, -2); // echo the string and get rid on the last comma and space
?>

 

Ray

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.