I am trying to create a list with array elements. It should add a comma after every element except for the last. I have the following code:
foreach ($srch as $value) {
$query .= "`" . $value . "`";
if (next($srch)){
$query .= ",";
}
}
It is adding a comma after everything except for the LAST TWO elements. Can someone help me understand this? I have read the php.net manual about next() and it seems like it should work for this purpose.
Also, I realize there are other ways to do this, but right now I would really like to understand next().