Re: [PHP] printing comma-delimited lists

2001-10-04 Thread David Otton

On Thu, 4 Oct 2001 16:27:11 +0200 (CEST), you wrote:

>You could try implode()
>
>$lis = implode(",", $arr);

That'll do it; thanks.

djo


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] printing comma-delimited lists

2001-10-04 Thread Stig-Ørjan Smelror

> What I'm doing here is fairly obvious (build a comma-delimited
>string).
> 
> $arr = array(1,2,3,4,5);
> 
> for ($i=0; $i< sizeof($arr); $i++) {
>   $lis = $lis . $arr[$i];
>   if ($i != (sizeof($arr)-1)) {
>   $lis = $lis . ',';
>   }
> }
> 
> 
> Question is, is there a more elegant way? I'm thinking of something
> like DTML's sequence-start and sequence-end, in a foreach
> construction.
> 
> djo
> 


You could try implode()

$lis = implode(",", $arr);


-- 
Stig-Ørjan Smelror
Systemutvikler

Linux Communications AS
Sandakerveien 48b
Box 1801 - Vika
N-0123 Oslo, Norway

tel. +47 22 09 28 80
fax. +47 22 09 28 81
http://www.lincom.no/




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] printing comma-delimited lists

2001-10-04 Thread David Otton

What I'm doing here is fairly obvious (build a comma-delimited
string).

$arr = array(1,2,3,4,5);

for ($i=0; $i< sizeof($arr); $i++) {
$lis = $lis . $arr[$i];
if ($i != (sizeof($arr)-1)) {
$lis = $lis . ',';
}
}


Question is, is there a more elegant way? I'm thinking of something
like DTML's sequence-start and sequence-end, in a foreach
construction.

djo


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]