I've gone through this address:
Passing an array to a query using a WHERE clause
and found that if I use a join clause to separate values ,
is also at the end of the array. How can I remove last?
I am using like this
$ttst=array();
$ttst=array();
$tt = "SELECT frd_id FROM network WHERE mem_id='$userId'";
$appLdone = execute_query($tt, true, "select");
foreach($appLdone as $kk=>$applist){
$ttst[] = $applist['frd_id'];
}
$result = implode(',', $ttst);
then also coming last ,
Thanks.
but it doesn't give single quote to each value .
join(',', array_filter($galleries))
array_filter
gets rid of empty elements that you seem to have. Of course, you should take care not to have empty elements in there in the first place.
You could use trim()
(or rtrim()
):
$myStr = 'planes,trains,automobiles,';
$myStr = trim($myStr, ',');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With