Thread: Array to List
View Single Post

  #1 (permalink)  
Old 08-11-2003
James Johnson
 
Posts: n/a
Default Array to List

Hello,

Coming from ColdFusion, this is difficult. CF has an ArrayToList() function.
I can't find anything similar in PHP.

I'm building a list from an array with the following code, but it puts a
trailing "," and I need to remove it.

$campusList = "";
foreach ($_POST['campus'] as $campus_ID){
$campusList .= $campus_ID;
$campusList .= ",";
}
print($campusList);

I've tried this:
if($campusList <> ""){
$chr = ",";
$campusList = strrchr($campusList,$chr);
}

But it removes everything from the list, except 1 ","

Thanks,
James

Reply With Quote