$i = 0;
while ($i < $cuenta) {
$actualizaInfoActualizar.= '$'.$campos[$i].', ';
$i++;
}
I want to remove the (,) that is generated in the last element, the others are fine.
$i = 0;
while ($i < $cuenta) {
$actualizaInfoActualizar.= '$'.$campos[$i].', ';
$i++;
}
I want to remove the (,) that is generated in the last element, the others are fine.
$i = 0;
while ($i < $cuenta) {
$actualizaInfoActualizar.= '$'.$campos[$i].', ';
$i++;
}
$actualizaInfoActualizar = rtrim($actualizaInfoActualizar,",");
There he is compadre.
You can control when the last element is written without a comma.
$i = 0;
while ($i < $cuenta) {
if($i == ($cuenta-1)){
$actualizaInfoActualizar.= '$'.$campos[$i];
}else{
$actualizaInfoActualizar.= '$'.$campos[$i].', ';
}
$i++;
}
The answer, make a substr()
, once the loop is finished:
$actualizaInfoActualizar = substr($actualizaInfoActualizar,0,-1);
And it would be already. I hope it serves you:)