substr && strlen

<?php
$aa = array(1,2,3);
$str = "";
foreach ($aa as $value) {
  $str .= $value . ", ";
}
echo substr($str, 0, strlen($str) - 2);
?>

Last updated