use the [man]count/man function to count the elements in the array. Then increment some number to keep track:
<?php
$max = count($aPropertiesForBinding)-1;
$i=0;
foreach($aPropertiesForBinding as $sCurrentKey => $sCurrentValue){
// do something
if($i<$max)
{
$sSql .= ', ';
}
else
{
// Last iteration
}
$i++;
}
Of course, if you're just building a query, and you know that you're going to have ", " after each element, just use substr to remove it:
foreach($aPropertiesForBinding as $sCurrentKey => $sCurrentValue){
// do something
$sSql .= ', ';
}
$sSql = substr($sSql, 0, -2);
EDIT:
Forgot the increment....