RE: [PHP] Array to List

From: Date: Mon, 11 Aug 2003 20:04:39 +0000
Subject: RE: [PHP] Array to List
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-159186@lists.php.net to get a copy of this message
Actually, I'm using $campusList for a SQL statement: SELECT name FROM campuses WHERE inst_id IN ('$campusList'); It wasn't working until I found out that $campusList needs to look like '1','2','3'. $campusList = implode( ', ', $_POST['campus'] ); Returns 4,2,3 (whatever was selected) I've looked in the manual on implode, but don't see how to surround each value with single quotes. Is there another function that will do this? Thanks, James -----Original Message----- From: Chris Boget [mailto:chris@wild.net] Sent: Monday, August 11, 2003 11:50 AM To: James Johnson; php-general@lists.php.net Subject: Re: [PHP] Array to List > Coming from ColdFusion, this is difficult. CF has an ArrayToList() > function. I can't find anything similar in PHP. implode(); > I'm building a list from an array with the following code, but it puts > a trailing "," and I need to remove it. [snip] $campusList = implode( ', ', $_POST['campus'] ); Simple as that. Read more about arrays here: http://www.php.net/manual/en/ref.array.php Chris

« previous php.general (#159186) next »