here am trying to add a comma in the values got by the foreach loop. now the values are coming all together, but i want it to get echoed as comma separated. please suggest me what i gotta do . I know, i gotta use implode, but i don’t know how to do it exactly in a loop.
foreach($_POST['insert'] as $interested) {
if(!preg_match('/^[-A-Z0-9\., ]+$/iD', $interested)) continue;
echo $interested;
}
If you want to leave your code relatively untouched (though I fixed your confusing indentation)…
…Or as one liners seem fashionable…