Array to List
| From: | James Johnson | Date: | Mon, 11 Aug 2003 18:44:19 +0000 |
| Subject: | Array to List | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-159172@lists.php.net to get a copy of this message | ||
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